Commit 09909d37 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵 Committed by Sebastian Dröge

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 '%'.
parent 35294f36
Pipeline #47490 passed with stages
in 46 minutes and 3 seconds
......@@ -1680,14 +1680,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment