diff --git a/CHANGES b/CHANGES index f1f2c7469..515b9c4e4 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ Bugfixes: - Qt: Fix locale being set to English on settings save (fixes mgba.io/i/906) - LR35902: Fix watchpoints not reporting new value - GBA Audio: Increase PSG volume (fixes mgba.io/i/932) + - GBA BIOS: Fix incorrect exit condition in LZ77 Misc: - GBA: Improve multiboot image detection - GB MBC: Remove erroneous bank 0 wrapping diff --git a/src/gba/bios.c b/src/gba/bios.c index 65014898e..a7c2a80b0 100644 --- a/src/gba/bios.c +++ b/src/gba/bios.c @@ -529,8 +529,10 @@ static void _unLz77(struct GBA* gba, int width) { source += 2; disp = dest - (block & 0x0FFF) - 1; bytes = (block >> 12) + 3; - while (bytes-- && remaining) { - --remaining; + while (bytes--) { + if (remaining) { + --remaining; + } if (width == 2) { byte = (int16_t) cpu->memory.load16(cpu, disp & ~1, 0); if (dest & 1) {