1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00

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.
This commit is contained in:
wm4 2015-03-29 13:40:19 +02:00
parent f82ddf1d0b
commit 4f7abd5e43

View File

@ -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)