summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-07 17:05:07 +0200
committerwm4 <wm4@nowhere>2013-06-07 17:05:07 +0200
commit6fc91b44cde1bfeecd0fccf29765a801bf2b42e1 (patch)
treec43de755ecd52a21122ba6fe6fbbb4ec97ef59d5 /core
parent925662b1935b9ad12fc057ebef236a5e3a96adf3 (diff)
downloadmpv-6fc91b44cde1bfeecd0fccf29765a801bf2b42e1.tar.bz2
mpv-6fc91b44cde1bfeecd0fccf29765a801bf2b42e1.tar.xz
m_option: allow setting empty lists
There's no reason why this should be forbidden.
Diffstat (limited to 'core')
-rw-r--r--core/m_option.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/m_option.c b/core/m_option.c
index 406e4ede0b..9ef968194f 100644
--- a/core/m_option.c
+++ b/core/m_option.c
@@ -996,7 +996,7 @@ static int parse_str_list(const m_option_t *opt, struct bstr name,
}
// All other ops need a param
- if (param.len == 0)
+ if (param.len == 0 && op != OP_NONE)
return M_OPT_MISSING_PARAM;
// custom type for "profile" calls this but uses ->priv for something else
@@ -1009,7 +1009,7 @@ static int parse_str_list(const m_option_t *opt, struct bstr name,
str = bstr_cut(str, 1);
n++;
}
- if (n == 0)
+ if (n == 0 && op != OP_NONE)
return M_OPT_INVALID;
if (((opt->flags & M_OPT_MIN) && (n < opt->min)) ||
((opt->flags & M_OPT_MAX) && (n > opt->max)))
@@ -1047,6 +1047,9 @@ static int parse_str_list(const m_option_t *opt, struct bstr name,
free_str_list(dst);
VAL(dst) = res;
+ if (!res[0])
+ free_str_list(dst);
+
return 1;
}