From d9764e8cea482fead7e1a3376d1007c884ee252b Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 21 Oct 2016 19:09:16 -0700 Subject: [PATCH] GB, GBA: Prevent loading null ROMs --- CHANGES | 1 + src/gb/gb.c | 3 +++ src/gba/gba.c | 3 +++ 3 files changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index 5e4ec7943..65e418644 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,7 @@ Misc: - VFS: Call msync when syncing mapped data - GBA Video, GB Video: Colors are now fully scaled - PSP2: Improved controller rumble + - GB, GBA: Prevent loading null ROMs 0.5.1: (2016-10-05) Bugfixes: diff --git a/src/gb/gb.c b/src/gb/gb.c index a4fab4ca9..28ceaf483 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -81,6 +81,9 @@ static void GBInit(void* cpu, struct mCPUComponent* component) { } bool GBLoadROM(struct GB* gb, struct VFile* vf) { + if (!vf) { + return false; + } GBUnloadROM(gb); gb->romVf = vf; gb->pristineRomSize = vf->size(vf); diff --git a/src/gba/gba.c b/src/gba/gba.c index 93ebc712b..3f5e82c04 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -490,6 +490,9 @@ bool GBALoadMB(struct GBA* gba, struct VFile* vf) { } bool GBALoadROM(struct GBA* gba, struct VFile* vf) { + if (!vf) { + return false; + } GBAUnloadROM(gba); gba->romVf = vf; gba->pristineRomSize = vf->size(vf);