mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-03-21 05:33:44 -04:00
pcm: fix stack allocation inside a loop
Using alloca in a loop can lead to a stack overflow. Fix by using malloc and free. Signed-off-by: Mingjie Shen <shen497@purdue.edu>
This commit is contained in:
parent
ed6b07084b
commit
250bb3e044
1 changed files with 6 additions and 1 deletions
|
|
@ -1172,7 +1172,10 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent
|
||||||
snd_config_t *jnode = snd_config_iterator_entry(j);
|
snd_config_t *jnode = snd_config_iterator_entry(j);
|
||||||
double value;
|
double value;
|
||||||
int ss;
|
int ss;
|
||||||
long *scha = alloca(tt_ssize * sizeof(long));
|
long *scha = malloc(tt_ssize * sizeof(long));
|
||||||
|
if (!scha) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
const char *id;
|
const char *id;
|
||||||
if (snd_config_get_id(jnode, &id) < 0)
|
if (snd_config_get_id(jnode, &id) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -1200,6 +1203,8 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent
|
||||||
if (schannel > sused)
|
if (schannel > sused)
|
||||||
sused = schannel;
|
sused = schannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(scha);
|
||||||
}
|
}
|
||||||
if (cchannel > cused)
|
if (cchannel > cused)
|
||||||
cused = cchannel;
|
cused = cchannel;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue