libav: avcfg: Don't leak duplicate enumvalue entries
authorEdward Hervey <edward@centricular.com>
Fri, 4 Nov 2022 06:59:10 +0000 (07:59 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 4 Nov 2022 17:59:21 +0000 (17:59 +0000)
If we discard the duplicates, we also need to free the allocated strings.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3319>

subprojects/gst-libav/ext/libav/gstavcfg.c

index a8635a7..afa9185 100644 (file)
@@ -147,6 +147,10 @@ register_enum (const AVClass ** obj, const AVOption * top_opt)
     while (i < values->len) {
       if (cur_val_set) {
         if (g_array_index (values, GEnumValue, i).value == cur_val) {
+          GEnumValue val = g_array_index (values, GEnumValue, i);
+          /* Don't leak the strings */
+          g_free ((gchar *) val.value_name);
+          g_free ((gchar *) val.value_nick);
           g_array_remove_index (values, i);
         } else {
           cur_val = g_array_index (values, GEnumValue, i).value;