all repos — mgba @ 07464e8f2b977ac703f13d36be7ed62742d190e5

mGBA Game Boy Advance Emulator

GBA: Cap out the ROM loaded size
Jeffrey Pfau jeffrey@endrift.com
Wed, 10 Dec 2014 01:44:22 -0800
commit

07464e8f2b977ac703f13d36be7ed62742d190e5

parent

47313497013c8802145cbe83d3c824f28e6fa5ab

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

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

@@ -424,7 +424,10 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname) {

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->pristineRomSize > SIZE_CART0) { + gba->pristineRomSize = SIZE_CART0; + } + gba->pristineRom = vf->map(vf, gba->pristineRomSize, MAP_READ); if (!gba->pristineRom) { GBALog(gba, GBA_LOG_WARN, "Couldn't map ROM"); return;