From 758019bf9263cb0e2b08b1dd7e0f15690c2e7a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 22 Jun 2024 01:21:18 +0200 Subject: [PATCH] m_options: fix obj settings list leak on error Fixes: b3b542af518742e0ac065f58ac52365af22e079b --- options/m_option.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/options/m_option.c b/options/m_option.c index 88ed04865c..ac773d1b84 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -3435,6 +3435,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, }; if (!obj_settings_list_insert_at(log, &res, -1, &item)) { obj_setting_free(&item); + free_obj_settings_list(&res); ret = M_OPT_OUT_OF_RANGE; goto done; } @@ -3464,6 +3465,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, if (label < 0) { if (!obj_settings_list_insert_at(log, &list, prepend_counter, &res[n])) { obj_setting_free(&res[n]); + free_obj_settings_list(&res); ret = M_OPT_OUT_OF_RANGE; goto done; } @@ -3482,6 +3484,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, if (label < 0) { if (!obj_settings_list_insert_at(log, &list, -1, &res[n])) { obj_setting_free(&res[n]); + free_obj_settings_list(&res); ret = M_OPT_OUT_OF_RANGE; goto done; } @@ -3511,6 +3514,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, if (found < 0) { if (!obj_settings_list_insert_at(log, &list, -1, &res[n])) { obj_setting_free(&res[n]); + free_obj_settings_list(&res); ret = M_OPT_OUT_OF_RANGE; goto done; }