From ee6ddeeaedf0db366a3ddf5b1f1959deeb53664c Mon Sep 17 00:00:00 2001 From: Norihiro Kamae Date: Wed, 8 Feb 2023 18:08:20 +0900 Subject: [PATCH] libobs: Avoid position underflow when mixing audio sources When a variable `pos` became larger than `AUDIO_OUTPUT_FRAMES`, `count` will get overflowed number. To avoid the overflow, continue the loop when `AUDIO_OUTPUT_FRAMES - pos` is not positive. --- libobs/obs-scene.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libobs/obs-scene.c b/libobs/obs-scene.c index c5fff5f92..c415268b8 100644 --- a/libobs/obs-scene.c +++ b/libobs/obs-scene.c @@ -1472,6 +1472,12 @@ static bool scene_audio_render(void *data, uint64_t *ts_out, pos = (size_t)ns_to_audio_frames(sample_rate, source_ts - timestamp); + + if (pos >= AUDIO_OUTPUT_FRAMES) { + item = item->next; + continue; + } + count = AUDIO_OUTPUT_FRAMES - pos; if (!apply_buf && !item->visible &&