From f31240a765b3220b8e1ee736ff3f6c41fea35a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 29 Dec 2015 17:54:44 +0200 Subject: [PATCH] encoding-profile: Don't use preset_name string after free When we run the loop for another time and do not have a preset name, we would try to print the preset name of a previous iteration that is already freed. Also move some other variables into the block where they are actually used to prevent similar mistakes in the future. CID 1346536 --- gst-libs/gst/pbutils/encoding-profile.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gst-libs/gst/pbutils/encoding-profile.c b/gst-libs/gst/pbutils/encoding-profile.c index 347ced4ac4..e613cbf1c1 100644 --- a/gst-libs/gst/pbutils/encoding-profile.c +++ b/gst-libs/gst/pbutils/encoding-profile.c @@ -1342,17 +1342,12 @@ combo_search (const gchar * pname) static GstEncodingProfile * parse_encoding_profile (const gchar * value) { - GstCaps *caps; GstEncodingProfile *res; - char *preset_name = NULL; - gchar **restriction_format, **preset_v; - - guint i, presence = 0; - GstCaps *restrictioncaps = NULL; gchar **strpresence_v, **strcaps_v = g_strsplit (value, ":", 0); + guint i; if (strcaps_v[0] && *strcaps_v[0]) { - caps = gst_caps_from_string (strcaps_v[0]); + GstCaps *caps = gst_caps_from_string (strcaps_v[0]); if (caps == NULL) { GST_ERROR ("Could not parse caps %s", strcaps_v[0]); return NULL; @@ -1368,6 +1363,11 @@ parse_encoding_profile (const gchar * value) for (i = 1; strcaps_v[i] && *strcaps_v[i]; i++) { GstEncodingProfile *profile = NULL; gchar *strcaps, *strpresence; + gchar *preset_name = NULL; + GstCaps *caps; + gchar **restriction_format, **preset_v; + guint presence = 0; + GstCaps *restrictioncaps = NULL; restriction_format = g_strsplit (strcaps_v[i], "->", 0); if (restriction_format[1]) { @@ -1449,8 +1449,7 @@ parse_encoding_profile (const gchar * value) if (res) { if (gst_encoding_container_profile_add_profile - (GST_ENCODING_CONTAINER_PROFILE (res), - profile) == FALSE) { + (GST_ENCODING_CONTAINER_PROFILE (res), profile) == FALSE) { g_warning ("Can not create a preset for caps: %s", strcaps_v[i]); return NULL;