]> git.alsa-project.org Git - alsa-lib.git/commitdiff
conf: fix memory leak in snd_config_substitute() for strings
authorJaroslav Kysela <perex@perex.cz>
Fri, 13 May 2022 14:19:48 +0000 (16:19 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 13 May 2022 14:19:50 +0000 (16:19 +0200)
When destination type is SND_CONFIG_TYPE_STRING, the old string
must be freed.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/conf.c

index 70f0e773b5c7554326d711dee89d45e5ba761649..e7f9e78c2fb31b85387f0f8384313fdbdf203634 100644 (file)
@@ -1741,6 +1741,8 @@ int snd_config_substitute(snd_config_t *dst, snd_config_t *src)
                src->u.compound.fields.prev->next = &dst->u.compound.fields;
        }
        free(dst->id);
+       if (dst->type == SND_CONFIG_TYPE_STRING)
+               free(dst->u.string);
        dst->id = src->id;
        dst->type = src->type;
        dst->u = src->u;