libav: avcfg: Don't leak duplicate enumvalue entries

If we discard the duplicates, we also need to free the allocated strings.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3319>
This commit is contained in:
Edward Hervey 2022-11-04 07:59:10 +01:00 committed by GStreamer Marge Bot
parent 97bfb8b6cb
commit cadc067bde

View 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;