diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2019-11-15 15:13:02 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2019-11-15 15:13:02 -0800 |
commit | 75875b67bf8a5a4142a5faaaab7a434a7b68772c (patch) | |
tree | 602173457c8cf24c326d8c084037dcc586aa66de /src | |
parent | e4cb7995ab7ffb0326e35ef15e6314abeabecd16 (diff) |
settings: check value in settings_apply_desc_generators()
Use setting_desc_check() before storing a value.
Diffstat (limited to 'src')
-rw-r--r-- | src/settings.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/settings.c b/src/settings.c index c7419e1..e5560b0 100644 --- a/src/settings.c +++ b/src/settings.c @@ -191,20 +191,28 @@ int settings_apply_desc_generators(const settings_t *settings, const setting_des for (i = 0; i < n_generators; i++) { const setting_desc_generator_t *g = &generators[i]; const char *value; + setting_desc_t *desc; + + desc = g->func(setup_context); + if (!desc) + return -ENOMEM; value = settings_get_value(settings, g->key); if (value) { + int r; + + r = setting_desc_check(desc, value); + setting_desc_free(desc); + if (r < 0) + return r; + if (g->value_ptr) *g->value_ptr = value; continue; } - next = g->func(setup_context); - if (!next) - return -ENOMEM; - - *next_setting = next; + *next_setting = desc; return 1; } |