From 8f2e2ec7b2bab20fa7018432010d04da871ca4ed Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 12 May 2025 17:29:29 -0500 Subject: [PATCH] prevent division by zero --- src/audio/sdlAudio.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/audio/sdlAudio.cpp b/src/audio/sdlAudio.cpp index bcf7f9212..1fab6e3ba 100644 --- a/src/audio/sdlAudio.cpp +++ b/src/audio/sdlAudio.cpp @@ -27,11 +27,15 @@ void taSDLProcess(void* inst, unsigned char* buf, int nframes) { } void TAAudioSDL::onProcess(unsigned char* buf, int nframes) { - unsigned int unframes=nframes/(sizeof(float)*desc.outChans); + unsigned int unframes=nframes/(sizeof(float)*MAX(1,desc.outChans)); if (nframes<0) { logE("nframes is negative! (%d)",nframes); return; } + if (desc.outChans<1) { + logE("outChans is less than 1!"); + return; + } for (int i=0; idesc.bufsize) { delete[] inBufs[i];