From: Jaroslav Kysela Date: Mon, 25 May 2026 10:34:37 +0000 (+0200) Subject: pcm: snd_pcm_slave_conf - fix C99 variable-length array allocation X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=33c9949e75593c09a5e08fa3f867a0734c8d5ca3;p=alsa-lib.git pcm: snd_pcm_slave_conf - fix C99 variable-length array allocation 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 --- 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;