summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-10-24 19:11:27 +0200
committerwm4 <wm4@nowhere>2013-10-24 22:50:13 +0200
commit8d5f8d5a6b6730d761fc622d279cbe45341d3314 (patch)
tree457b6156da32b67c1b062c647761c5737be0a028 /mpvcore
parentcc235d203d26b242b34d899f89a4ab6d2086ef88 (diff)
downloadmpv-8d5f8d5a6b6730d761fc622d279cbe45341d3314.tar.bz2
mpv-8d5f8d5a6b6730d761fc622d279cbe45341d3314.tar.xz
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.)
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/m_config.c19
1 files changed, 7 insertions, 12 deletions
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);
}
}
}