mirror of https://github.com/mpv-player/mpv
options: fix key-value-list options
The parser can be called with dst (the target) set to NULL if the option should be verified only. The code didn't respect this, and could result in crashes when used in config profiles or filter sub-options. Fixes #981.
This commit is contained in:
parent
43ddf2099b
commit
9a6d7af074
|
@ -1399,13 +1399,16 @@ static int parse_keyvalue_list(struct mp_log *log, const m_option_t *opt,
|
|||
r = read_subparam(log, name, ¶m, &val);
|
||||
if (r < 0)
|
||||
break;
|
||||
MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, key));
|
||||
MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, val));
|
||||
if (dst) {
|
||||
MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, key));
|
||||
MP_TARRAY_APPEND(NULL, lst, num, bstrto0(NULL, val));
|
||||
}
|
||||
|
||||
if (!bstr_eatstart0(¶m, ","))
|
||||
break;
|
||||
}
|
||||
MP_TARRAY_APPEND(NULL, lst, num, NULL);
|
||||
if (dst)
|
||||
MP_TARRAY_APPEND(NULL, lst, num, NULL);
|
||||
|
||||
if (param.len) {
|
||||
mp_err(log, "Unparseable garbage at end of option value: '%.*s'\n",
|
||||
|
@ -1413,9 +1416,11 @@ static int parse_keyvalue_list(struct mp_log *log, const m_option_t *opt,
|
|||
r = M_OPT_INVALID;
|
||||
}
|
||||
|
||||
VAL(dst) = lst;
|
||||
if (r < 0)
|
||||
free_str_list(dst);
|
||||
if (dst) {
|
||||
VAL(dst) = lst;
|
||||
if (r < 0)
|
||||
free_str_list(dst);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue