From 6fa009794a45da49ee14a6dc056598ca39b6af1d Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Tue, 21 Apr 2026 17:08:52 +0000 Subject: [PATCH] alsa: Add frame validation in stream_buffer_decrement --- src/cubeb_alsa.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cubeb_alsa.c b/src/cubeb_alsa.c index f114f27d7..be9faa490 100644 --- a/src/cubeb_alsa.c +++ b/src/cubeb_alsa.c @@ -294,6 +294,9 @@ set_timeout(struct timeval * timeout, unsigned int ms) static void stream_buffer_decrement(cubeb_stream * stm, long count) { + if (count < 0 || (snd_pcm_uframes_t)count > stm->bufframes) { + count = stm->bufframes; + } char * bufremains = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, count); memmove(stm->buffer, bufremains,