From 103cae25917d95f8e5f7360be349ac6ebdcc1a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 23 Jun 2024 19:31:15 +0200 Subject: [PATCH] m_option: ignore excessive elements only for obj_settings_list It makes sense to allow the first part of the list. There are warnings about excessive elements already. This also allows overriding elements with the same label. --- options/m_option.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/options/m_option.c b/options/m_option.c index 0dc0f3e399..e17bdaf6a7 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -3275,10 +3275,8 @@ done: ; .enabled = enabled, .attribs = plist, }; - if (!obj_settings_list_insert_at(log, _ret, -1, &item)) { + if (!obj_settings_list_insert_at(log, _ret, -1, &item)) obj_setting_free(&item); - return M_OPT_OUT_OF_RANGE; - } return 1; } @@ -3433,12 +3431,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, m_obj_settings_t item = { .name = talloc_strdup(NULL, ""), }; - if (!obj_settings_list_insert_at(log, &res, -1, &item)) { + 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; - } } } } @@ -3463,12 +3457,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, for (int n = 0; res && res[n].name; n++) { int label = obj_settings_list_find_by_label0(list, res[n].label); if (label < 0) { - if (!obj_settings_list_insert_at(log, &list, prepend_counter, &res[n])) { + 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; - } prepend_counter++; } else { // Prefer replacement semantics, instead of actually @@ -3482,12 +3472,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, for (int n = 0; res && res[n].name; n++) { int label = obj_settings_list_find_by_label0(list, res[n].label); if (label < 0) { - if (!obj_settings_list_insert_at(log, &list, -1, &res[n])) { + 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; - } } else { // Prefer replacement semantics, instead of actually // appending. @@ -3512,12 +3498,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, } else { int found = obj_settings_find_by_content(list, &res[n]); if (found < 0) { - if (!obj_settings_list_insert_at(log, &list, -1, &res[n])) { + 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; - } } else { obj_settings_list_del_at(&list, found); obj_setting_free(&res[n]);