]> git.alsa-project.org Git - alsa-lib.git/commitdiff
configuration: added one more alias check to detect a circular configuration
authorJaroslav Kysela <perex@perex.cz>
Thu, 28 Sep 2006 14:42:19 +0000 (16:42 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 28 Sep 2006 14:42:19 +0000 (16:42 +0200)
src/conf.c

index cb87df569794735f927db22be071bd284e670643..f1626d889e7d3226747483d393d84d6951a60aa5 100644 (file)
@@ -2405,7 +2405,7 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
 { \
        snd_config_t *res = NULL; \
        char *old_key; \
-       int err, first = 1; \
+       int err, first = 1, maxloop = 1000; \
        assert(config && key); \
        while (1) { \
                old_key = strdup(key); \
@@ -2424,14 +2424,18 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
                } \
                if (snd_config_get_string(res, &key) < 0) \
                        break; \
-               if (!first && strcmp(key, old_key) == 0) { \
-                       SNDERR("key %s refers to itself"); \
+               if (!first && (strcmp(key, old_key) == 0 || maxloop <= 0)) { \
+                       if (maxloop == 0) \
+                               SNDERR("maximum loop count reached (circular configuration?)"); \
+                       else \
+                               SNDERR("key %s refers to itself", key); \
                        err = -EINVAL; \
                        res = NULL; \
                        break; \
                } \
                free(old_key); \
                first = 0; \
+               maxloop--; \
        } \
        free(old_key); \
        if (!res) \