From 4f7abd5e43796c8d47cf0d33546fb647cd137cb3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 29 Mar 2015 13:40:19 +0200 Subject: 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. --- options/m_config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'options') 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) -- cgit v1.2.3