ucm: uc_mgr_substitute_tree() fix use after free

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-01-07 17:41:38 +01:00
parent 51e1d486ce
commit 3f63dc2644

View file

@ -417,11 +417,12 @@ int uc_mgr_substitute_tree(snd_use_case_mgr_t *uc_mgr, snd_config_t *node)
if (err < 0) if (err < 0)
return err; return err;
err = snd_config_set_id(node, s); err = snd_config_set_id(node, s);
free(s);
if (err < 0) { if (err < 0) {
uc_error("unable to set substituted id '%s' (old id '%s')", s, id); uc_error("unable to set substituted id '%s' (old id '%s')", s, id);
free(s);
return err; return err;
} }
free(s);
} }
if (snd_config_get_type(node) != SND_CONFIG_TYPE_COMPOUND) { if (snd_config_get_type(node) != SND_CONFIG_TYPE_COMPOUND) {
if (snd_config_get_type(node) == SND_CONFIG_TYPE_STRING) { if (snd_config_get_type(node) == SND_CONFIG_TYPE_STRING) {