diff options
author | wm4 <wm4@nowhere> | 2014-08-05 02:24:45 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-08-05 02:24:45 +0200 |
commit | 9a6d7af0749b6135994a1b35158217535607e682 (patch) | |
tree | 02ae033750e330071a6c1048efbcad6f012b11ff /options | |
parent | 43ddf2099baf01ae22985f60e0f735a00f578844 (diff) | |
download | mpv-9a6d7af0749b6135994a1b35158217535607e682.tar.bz2 mpv-9a6d7af0749b6135994a1b35158217535607e682.tar.xz |
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.
Diffstat (limited to 'options')
-rw-r--r-- | options/m_option.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/options/m_option.c b/options/m_option.c index 52dd18b9d2..e11f96bbcc 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -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; } |