summaryrefslogtreecommitdiffstats
path: root/options/m_config_frontend.c
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-10-22 19:38:58 +0200
committersfan5 <sfan5@live.de>2023-10-23 20:33:51 +0200
commit1805681aaba22aa19a27ecfdb639c983d91f83e6 (patch)
tree755dfebed879c474f6f55b5e7b6efbf66b5693c9 /options/m_config_frontend.c
parent907443686242dfb9636ac5b604581f484e5fca7f (diff)
downloadmpv-1805681aaba22aa19a27ecfdb639c983d91f83e6.tar.bz2
mpv-1805681aaba22aa19a27ecfdb639c983d91f83e6.tar.xz
m_option: initialize m_option_value union properly
C standard says that `= {0}` activates and initializes first member of union. We expect whole union to be zeroed, it is used as default value. Initialize union with one zeroed default instance to ensure proper init. Fixes: #12711
Diffstat (limited to 'options/m_config_frontend.c')
-rw-r--r--options/m_config_frontend.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/options/m_config_frontend.c b/options/m_config_frontend.c
index 44cb9fd834..e95b350849 100644
--- a/options/m_config_frontend.c
+++ b/options/m_config_frontend.c
@@ -749,7 +749,7 @@ int m_config_set_option_cli(struct m_config *config, struct bstr name,
BSTR_P(name), BSTR_P(param), flags);
}
- union m_option_value val = {0};
+ union m_option_value val = m_option_value_default;
// Some option types are "impure" and work on the existing data.
// (Prime examples: --vf-add, --sub-file)
@@ -783,7 +783,7 @@ int m_config_set_option_node(struct m_config *config, bstr name,
// Do this on an "empty" type to make setting the option strictly overwrite
// the old value, as opposed to e.g. appending to lists.
- union m_option_value val = {0};
+ union m_option_value val = m_option_value_default;
if (data->format == MPV_FORMAT_STRING) {
bstr param = bstr0(data->u.string);
@@ -868,9 +868,8 @@ void m_config_print_option_list(const struct m_config *config, const char *name)
}
char *def = NULL;
const void *defptr = m_config_get_co_default(config, co);
- const union m_option_value default_value = {0};
if (!defptr)
- defptr = &default_value;
+ defptr = &m_option_value_default;
if (defptr)
def = m_option_pretty_print(opt, defptr);
if (def) {