diff --git a/CHANGES b/CHANGES index 107e45c50..ada5bd698 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Emulation fixes: - GBA GPIO: Fix gyro read-out start (fixes mgba.io/i/3141) - GBA SIO: Fix MULTI mode SIOCNT bit 7 writes on secondary GBAs (fixes mgba.io/i/3110) Other fixes: + - GBA Audio: Fix crash if audio FIFOs and timers get out of sync - GBA Memory: Let raw access read high MMIO addresses - Qt: Fix crash when applying changes to GB I/O registers in I/O view - Qt: Fix LCDC background priority/enable bit being mis-mapped in I/O view diff --git a/src/gba/audio.c b/src/gba/audio.c index d225d5937..e03dcc006 100644 --- a/src/gba/audio.c +++ b/src/gba/audio.c @@ -357,6 +357,9 @@ void GBAAudioSampleFIFO(struct GBAAudio* audio, int fifoId, int32_t cycles) { int bits = 2 << GBARegisterSOUNDBIASGetResolution(audio->soundbias); until += 1 << (9 - GBARegisterSOUNDBIASGetResolution(audio->soundbias)); until >>= 9 - GBARegisterSOUNDBIASGetResolution(audio->soundbias); + if (UNLIKELY(bits < until)) { + until = bits; + } int i; for (i = bits - until; i < bits; ++i) { channel->samples[i] = channel->internalSample;