conf.c: snd_config_add: prevent adopting a non-orphan

When adding a configuration node to another, check that the child node
does not already have a parent.  Otherwise, the old parent's children
list would become corrupted.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
This commit is contained in:
Clemens Ladisch 2009-07-15 11:20:29 +02:00
parent 76c60af00a
commit 5d56a11a8e

View file

@ -1649,7 +1649,7 @@ int snd_config_add(snd_config_t *father, snd_config_t *leaf)
{
snd_config_iterator_t i, next;
assert(father && leaf);
if (!leaf->id)
if (!leaf->id || leaf->father)
return -EINVAL;
snd_config_for_each(i, next, father) {
snd_config_t *n = snd_config_iterator_entry(i);