all repos — mgba @ e104b465640fe584cc6fd402d3c78e57e9819905

mGBA Game Boy Advance Emulator

GBA BIOS: Add warning for LZ77 error causing BIOS to hang (closes #879)
Vicki Pfau vi@endrift.com
Thu, 16 Nov 2017 09:22:15 -0800
commit

e104b465640fe584cc6fd402d3c78e57e9819905

parent

388ed07074163f135989838633eea8f1c8416023

1 files changed, 5 insertions(+), 1 deletions(-)

jump to
M src/gba/bios.csrc/gba/bios.c

@@ -529,7 +529,11 @@ int block = cpu->memory.load8(cpu, source + 1, 0) | (cpu->memory.load8(cpu, source, 0) << 8);

source += 2; disp = dest - (block & 0x0FFF) - 1; bytes = (block >> 12) + 3; - while (bytes-- && remaining) { + while (bytes--) { + if (!remaining) { + mLOG(GBA_BIOS, GAME_ERROR, "Improperly compressed LZ77 data. Real BIOS would hang."); + break; + } --remaining; if (width == 2) { byte = (int16_t) cpu->memory.load16(cpu, disp & ~1, 0);