all repos — mgba @ 3c844a9ae9e6de6c1aae1eb5b627ce1d3aa334bc

mGBA Game Boy Advance Emulator

GBA Memory: Soft-crash if jumping past the end of a ROM
Jeffrey Pfau jeffrey@endrift.com
Fri, 08 May 2015 00:34:01 -0700
commit

3c844a9ae9e6de6c1aae1eb5b627ce1d3aa334bc

parent

924efefc3839a3745bf9e4e6da419bacdda9b4ef

2 files changed, 18 insertions(+), 11 deletions(-)

jump to
M CHANGESCHANGES

@@ -53,6 +53,7 @@ - Qt: Move GL frame drawing back onto its own thread

- GBA: Add status log level - GBA Thread: Add functionality for running callbacks on the GBA thread - Qt: Fast forward (held) option moved from Other to Emulation menu + - GBA Memory: Soft-crash if jumping past the end of a ROM 0.2.0: (2015-04-03) Features:
M src/gba/memory.csrc/gba/memory.c

@@ -231,6 +231,12 @@ }

} gba->lastJump = address; + if (newRegion >= REGION_CART0 && (address & (SIZE_CART0 - 1)) >= memory->romSize) { + cpu->memory.activeRegion = _deadbeef; + cpu->memory.activeMask = 0; + GBALog(gba, GBA_LOG_FATAL, "Jumped past end of ROM"); + return; + } if (newRegion == memory->activeRegion) { return; }

@@ -239,29 +245,29 @@ if (memory->activeRegion == REGION_BIOS) {

memory->biosPrefetch = cpu->prefetch[1]; } memory->activeRegion = newRegion; - switch (address & ~OFFSET_MASK) { - case BASE_BIOS: + switch (newRegion) { + case REGION_BIOS: cpu->memory.activeRegion = memory->bios; cpu->memory.activeMask = SIZE_BIOS - 1; break; - case BASE_WORKING_RAM: + case REGION_WORKING_RAM: cpu->memory.activeRegion = memory->wram; cpu->memory.activeMask = SIZE_WORKING_RAM - 1; break; - case BASE_WORKING_IRAM: + case REGION_WORKING_IRAM: cpu->memory.activeRegion = memory->iwram; cpu->memory.activeMask = SIZE_WORKING_IRAM - 1; break; - case BASE_VRAM: + case REGION_VRAM: cpu->memory.activeRegion = (uint32_t*) gba->video.renderer->vram; cpu->memory.activeMask = 0x0000FFFF; break; - case BASE_CART0: - case BASE_CART0_EX: - case BASE_CART1: - case BASE_CART1_EX: - case BASE_CART2: - case BASE_CART2_EX: + case REGION_CART0: + case REGION_CART0_EX: + case REGION_CART1: + case REGION_CART1_EX: + case REGION_CART2: + case REGION_CART2_EX: cpu->memory.activeRegion = memory->rom; cpu->memory.activeMask = SIZE_CART0 - 1; break;