all repos — mgba @ 510fddb23f72de55615a8026498ec0a48380a947

mGBA Game Boy Advance Emulator

GBA: Error check to make sure ROM and BIOS mapping succeed
Jeffrey Pfau jeffrey@endrift.com
Tue, 09 Dec 2014 15:19:51 -0800
commit

510fddb23f72de55615a8026498ec0a48380a947

parent

794d8051228a5b157698b3bdc3d349a994c92370

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

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

@@ -425,6 +425,10 @@ gba->romVf = vf;

gba->pristineRomSize = vf->seek(vf, 0, SEEK_END); vf->seek(vf, 0, SEEK_SET); gba->pristineRom = vf->map(vf, SIZE_CART0, MAP_READ); + if (!gba->pristineRom) { + GBALog(gba, GBA_LOG_WARN, "Couldn't map ROM"); + return; + } gba->memory.rom = gba->pristineRom; gba->activeFile = fname; gba->memory.romSize = gba->pristineRomSize;

@@ -437,7 +441,12 @@ }

void GBALoadBIOS(struct GBA* gba, struct VFile* vf) { gba->biosVf = vf; - gba->memory.bios = vf->map(vf, SIZE_BIOS, MAP_READ); + uint32_t* bios = vf->map(vf, SIZE_BIOS, MAP_READ); + if (!bios) { + GBALog(gba, GBA_LOG_WARN, "Couldn't map BIOS"); + return; + } + gba->memory.bios = bios; gba->memory.fullBios = 1; uint32_t checksum = GBAChecksum(gba->memory.bios, SIZE_BIOS); GBALog(gba, GBA_LOG_DEBUG, "BIOS Checksum: 0x%X", checksum);