summaryrefslogtreecommitdiffstats
path: root/m_option.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-06-29 05:14:26 +0300
committerUoti Urpala <uau@mplayer2.org>2012-07-16 21:08:42 +0300
commit86571435baf116a91a31451d26224600f3575270 (patch)
treeaf013eb73a698e577817b806514b20845b8f3602 /m_option.c
parent9426c5f92aab4b561c568e4250f5b250e2aa45c5 (diff)
downloadmpv-86571435baf116a91a31451d26224600f3575270.tar.bz2
mpv-86571435baf116a91a31451d26224600f3575270.tar.xz
options: fix specifying string options without parameter
Specifying a string option with no parameter, as in "--dumpfile" with no '=', erroneously set the corresponding variable to NULL. Fix this to give an error about missing parameter instead. Suboption parsing explicitly treated empty option values as if the option had been specified with no value (no '='). Thus it was not possible to specify empty strings as values. I think this behavior was originally added only because of other limitations in the old implementation. Remove it, so that suboptions now behave the same as top-level ones in this regard. Document the NULL-distinguishing property of bstrdup0() that the code depends on, and also make bstrdup() behave consistently.
Diffstat (limited to 'm_option.c')
-rw-r--r--m_option.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/m_option.c b/m_option.c
index 23343c73a6..18f94dc7a9 100644
--- a/m_option.c
+++ b/m_option.c
@@ -458,6 +458,9 @@ static int parse_str(const m_option_t *opt, struct bstr name,
struct bstr param, bool ambiguous_param, void *dst,
void *talloc_ctx)
{
+ if (param.start == NULL)
+ return M_OPT_MISSING_PARAM;
+
if ((opt->flags & M_OPT_MIN) && (param.len < opt->min)) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
"Parameter must be >= %d chars: %.*s\n",
@@ -891,8 +894,7 @@ static int parse_subconf(const m_option_t *opt, struct bstr name,
if (dst) {
lst = talloc_realloc(NULL, lst, char *, 2 * (nr + 2));
lst[2 * nr] = bstrdup0(lst, subopt);
- lst[2 * nr + 1] = subparam.len == 0 ? NULL :
- bstrdup0(lst, subparam);
+ lst[2 * nr + 1] = bstrdup0(lst, subparam);
memset(&lst[2 * (nr + 1)], 0, 2 * sizeof(char *));
nr++;
}