diff options
author | wm4 <wm4@nowhere> | 2015-03-29 13:40:19 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-29 13:44:34 +0200 |
commit | 4f7abd5e43796c8d47cf0d33546fb647cd137cb3 (patch) | |
tree | b0733330688c685c0491c1123da73cec378bc3dc /options | |
parent | f82ddf1d0b05ceecfd3316ebb18dce99c51b935c (diff) | |
download | mpv-4f7abd5e43796c8d47cf0d33546fb647cd137cb3.tar.bz2 mpv-4f7abd5e43796c8d47cf0d33546fb647cd137cb3.tar.xz |
m_config: remove assertion for option names with length 0
There's actually no reason why we should assert. It's unexpected and
"should" not happen, but actually there are several ways to make it
happen.
Still, add a check m_config_get_co(), to avoid matching pseudo-entries
with no name.
Diffstat (limited to 'options')
-rw-r--r-- | options/m_config.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/options/m_config.c b/options/m_config.c index 43fd508a9d..5925b7a159 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -453,7 +453,9 @@ static void m_config_add_option(struct m_config *config, struct m_config_option *m_config_get_co(const struct m_config *config, struct bstr name) { - const char *prefix = config->is_toplevel ? "--" : ""; + if (!name.len) + return NULL; + for (int n = 0; n < config->num_opts; n++) { struct m_config_option *co = &config->opts[n]; struct bstr coname = bstr0(co->name); @@ -466,6 +468,7 @@ struct m_config_option *m_config_get_co(const struct m_config *config, } else if (bstrcmp(coname, name) == 0) matches = true; if (matches) { + const char *prefix = config->is_toplevel ? "--" : ""; if (co->opt->type == &m_option_type_alias) { const char *alias = (const char *)co->opt->priv; if (!co->warning_was_printed) { @@ -590,7 +593,6 @@ static int m_config_parse_option(struct m_config *config, struct bstr name, struct bstr param, int flags) { assert(config != NULL); - assert(name.len != 0); struct m_config_option *co = m_config_get_co(config, name); if (!co) |