From 33c9949e75593c09a5e08fa3f867a0734c8d5ca3 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 25 May 2026 12:34:37 +0200 Subject: [PATCH] pcm: snd_pcm_slave_conf - fix C99 variable-length array allocation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The C standard (C99 §6.7.5.2p1) requires VLA bounds to be greater than zero; a bound of 0 is undefined behavior. Reported by UBSan. Fixes: https://github.com/alsa-project/alsa-lib/issues/505 Signed-off-by: Jaroslav Kysela --- src/pcm/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 11b15100..f2831ed7 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -7824,7 +7824,7 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf, int flags; void *ptr; int present; - } fields[count]; + } fields[count > 0 ? count : 1]; unsigned int k; snd_config_t *pcm_conf = NULL; int err; -- 2.52.0