mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-03-01 01:40:07 -05:00
configuration: added one more alias check to detect a circular configuration
This commit is contained in:
parent
1dc96732c2
commit
35b1df509f
1 changed files with 7 additions and 3 deletions
10
src/conf.c
10
src/conf.c
|
|
@ -2405,7 +2405,7 @@ int snd_config_save(snd_config_t *config, snd_output_t *out)
|
||||||
{ \
|
{ \
|
||||||
snd_config_t *res = NULL; \
|
snd_config_t *res = NULL; \
|
||||||
char *old_key; \
|
char *old_key; \
|
||||||
int err, first = 1; \
|
int err, first = 1, maxloop = 1000; \
|
||||||
assert(config && key); \
|
assert(config && key); \
|
||||||
while (1) { \
|
while (1) { \
|
||||||
old_key = strdup(key); \
|
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) \
|
if (snd_config_get_string(res, &key) < 0) \
|
||||||
break; \
|
break; \
|
||||||
if (!first && strcmp(key, old_key) == 0) { \
|
if (!first && (strcmp(key, old_key) == 0 || maxloop <= 0)) { \
|
||||||
SNDERR("key %s refers to itself"); \
|
if (maxloop == 0) \
|
||||||
|
SNDERR("maximum loop count reached (circular configuration?)"); \
|
||||||
|
else \
|
||||||
|
SNDERR("key %s refers to itself", key); \
|
||||||
err = -EINVAL; \
|
err = -EINVAL; \
|
||||||
res = NULL; \
|
res = NULL; \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
free(old_key); \
|
free(old_key); \
|
||||||
first = 0; \
|
first = 0; \
|
||||||
|
maxloop--; \
|
||||||
} \
|
} \
|
||||||
free(old_key); \
|
free(old_key); \
|
||||||
if (!res) \
|
if (!res) \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue