]> git.alsa-project.org Git - alsa-lib.git/commitdiff
conf.c: snd_config_add: prevent adopting a non-orphan
authorClemens Ladisch <clemens@ladisch.de>
Wed, 15 Jul 2009 09:20:29 +0000 (11:20 +0200)
committerClemens Ladisch <clemens@ladisch.de>
Wed, 15 Jul 2009 09:20:29 +0000 (11:20 +0200)
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>
src/conf.c

index 97bf5e126bad4df0330338ba7abd25c9badc5695..ccaeb3c19ef53dbb93cff114060c542f1f8cc327 100644 (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);