If source configuration node has a parent set, it must be always
detached to avoid memory corruptions.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
*/
int snd_config_substitute(snd_config_t *dst, snd_config_t *src)
{
- assert(dst && src);
+ assert(dst && src && src != dst);
if (dst->type == SND_CONFIG_TYPE_COMPOUND) {
int err = snd_config_delete_compound_members(dst);
if (err < 0)
free(dst->id);
if (dst->type == SND_CONFIG_TYPE_STRING)
free(dst->u.string);
+ if (src->parent) /* like snd_config_remove */
+ list_del(&src->list);
dst->id = src->id;
dst->type = src->type;
dst->u = src->u;
if (override ||
sn->type != SND_CONFIG_TYPE_COMPOUND ||
dn->type != SND_CONFIG_TYPE_COMPOUND) {
- snd_config_remove(sn);
err = snd_config_substitute(dn, sn);
if (err < 0)
return err;