mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 18:35:35 +00:00
aggregator: Make parsing of explicit sink pad names more robust
When passing "sink_%d" twice to aggregator before it would create two pads called "sink_0", because it failed to parse "%d" as integer and used 0 instead then. Instead validate that parsing was actually successful and also don't even try to parse if the requested pad name contains a '%'.
This commit is contained in:
parent
53bf06c088
commit
99aeb91cc0
1 changed files with 12 additions and 4 deletions
|
@ -1669,14 +1669,22 @@ gst_aggregator_default_create_new_pad (GstAggregator * self,
|
|||
|
||||
GST_OBJECT_LOCK (self);
|
||||
if (req_name == NULL || strlen (req_name) < 6
|
||||
|| !g_str_has_prefix (req_name, "sink_")) {
|
||||
|| !g_str_has_prefix (req_name, "sink_")
|
||||
|| strrchr (req_name, '%') != NULL) {
|
||||
/* no name given when requesting the pad, use next available int */
|
||||
serial = ++priv->max_padserial;
|
||||
} else {
|
||||
gchar *endptr = NULL;
|
||||
|
||||
/* parse serial number from requested padname */
|
||||
serial = g_ascii_strtoull (&req_name[5], NULL, 10);
|
||||
if (serial > priv->max_padserial)
|
||||
priv->max_padserial = serial;
|
||||
serial = g_ascii_strtoull (&req_name[5], &endptr, 10);
|
||||
if (endptr != NULL && *endptr == '\0') {
|
||||
if (serial > priv->max_padserial) {
|
||||
priv->max_padserial = serial;
|
||||
}
|
||||
} else {
|
||||
serial = ++priv->max_padserial;
|
||||
}
|
||||
}
|
||||
|
||||
name = g_strdup_printf ("sink_%u", serial);
|
||||
|
|
Loading…
Reference in a new issue