From 8d5f8d5a6b6730d761fc622d279cbe45341d3314 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 24 Oct 2013 19:11:27 +0200 Subject: m_config: don't allow aliasing with string options Minor simplification. String options are now not allowed to use the same variable/field anymore. (Also affects other "dynamic" options which require memory allocation.) --- mpvcore/m_config.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'mpvcore') diff --git a/mpvcore/m_config.c b/mpvcore/m_config.c index 4ea5b54d17..0affe0d6ee 100644 --- a/mpvcore/m_config.c +++ b/mpvcore/m_config.c @@ -422,20 +422,15 @@ static struct m_config_option *m_config_add_option(struct m_config *config, // clear the original option (to stop m_option from freeing the // static data), copy it back. // This would leak memory when done on aliased options. - bool aliased = false; for (struct m_config_option *i = config->opts; i; i = i->next) { - if (co->data == i->data) { - aliased = true; - break; - } - } - if (!aliased) { - union m_option_value temp = {0}; - m_option_copy(arg, &temp, co->data); - memset(co->data, 0, arg->type->size); - m_option_copy(arg, co->data, &temp); - m_option_free(arg, &temp); + if (co->data == i->data) + assert(0); } + union m_option_value temp = {0}; + m_option_copy(arg, &temp, co->data); + memset(co->data, 0, arg->type->size); + m_option_copy(arg, co->data, &temp); + m_option_free(arg, &temp); } } } -- cgit v1.2.3