From a69ac97e4d5f3416158e12d97778f6fb098fbb52 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 24 Jan 2024 18:20:44 +0100 Subject: [PATCH] pcm: route plugin: allocate temporary array on stack only one time Fixes: https://github.com/alsa-project/alsa-lib/pull/363 Signed-off-by: Jaroslav Kysela --- src/pcm/pcm_route.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 38057cb2..affb929f 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -1151,6 +1151,11 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent snd_config_iterator_t i, inext; unsigned int k; int err; + + long *scha = alloca(tt_ssize * sizeof(long)); + if (scha == NULL) + return -ENOMEM; + for (k = 0; k < tt_csize * tt_ssize; ++k) ttable[k] = 0.0; snd_config_for_each(i, inext, tt) { @@ -1172,7 +1177,6 @@ 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)); const char *id; if (snd_config_get_id(jnode, &id) < 0) continue; -- 2.47.1