mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-05 04:06:34 -05: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);
|
||||
double value;
|
||||
int ss;
|
||||
long *scha = alloca(tt_ssize * sizeof(long));
|
||||
long *scha = malloc(tt_ssize * sizeof(long));
|
||||
if (!scha) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
const char *id;
|
||||
if (snd_config_get_id(jnode, &id) < 0)
|
||||
continue;
|
||||
|
|
@ -1200,6 +1203,8 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent
|
|||
if (schannel > sused)
|
||||
sused = schannel;
|
||||
}
|
||||
|
||||
free(scha);
|
||||
}
|
||||
if (cchannel > cused)
|
||||
cused = cchannel;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue