From: Sebastian Dröge Date: Mon, 8 Jul 2019 16:09:03 +0000 (+0300) Subject: aggregator: Make parsing of explicit sink pad names more robust X-Git-Tag: 1.19.3~1118 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09909d37bdcac38432c1de2ff7b4b0a6a155e14e;p=platform%2Fupstream%2Fgstreamer.git 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 '%'. --- diff --git a/libs/gst/base/gstaggregator.c b/libs/gst/base/gstaggregator.c index 079dd0bf89..28164cb18d 100644 --- a/libs/gst/base/gstaggregator.c +++ b/libs/gst/base/gstaggregator.c @@ -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);