From 3041bd0ba948d2ad96e90e94e3b3a3ffc535d078 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 6 Aug 2026 16:14:52 +0500 Subject: [PATCH] engine: client: sound: clamp mixed sample count to requested amount, fixes paintbuffer overflow with timecompressed VOX --- engine/client/sound/s_mix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engine/client/sound/s_mix.c b/engine/client/sound/s_mix.c index a8c9fcc6..fe5ece45 100644 --- a/engine/client/sound/s_mix.c +++ b/engine/client/sound/s_mix.c @@ -250,6 +250,9 @@ static int S_MixChannelToBuffer( portable_samplepair_t *pbuf, channel_t *chan, i out_count = (int)floor(( available - 1 - sample_frac ) / rate ); else out_count = (int)ceil(( available - sample_frac ) / rate ); + + if( out_count > num_samples ) + out_count = num_samples; } // near a buffer boundary (e.g. just before a loop wrap) lerp may yield zero;