diff --git a/CHANGES b/CHANGES index 0d07caded..aab94343c 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,7 @@ Bugfixes: - GBA Video: Don't update background scanline params in mode 0 (fixes mgba.io/i/377) - Core: Fix crash with rewind if savestates shrink - Test: Fix crash when loading invalid file + - GBA Hardware: Fix crash if a savestate lies about game hardware Misc: - Qt: Improved HiDPI support - Feature: Support ImageMagick 7 diff --git a/src/gba/gba.c b/src/gba/gba.c index 704b93744..ac07e5635 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -82,6 +82,8 @@ static void GBAInit(void* cpu, struct mCPUComponent* component) { gba->timersEnabled = 0; memset(gba->timers, 0, sizeof(gba->timers)); + GBAHardwareInit(&gba->memory.hw, NULL); + gba->springIRQ = 0; gba->keySource = 0; gba->rotationSource = 0; diff --git a/src/gba/hardware.c b/src/gba/hardware.c index 0a2b60bb1..73f11381d 100644 --- a/src/gba/hardware.c +++ b/src/gba/hardware.c @@ -73,6 +73,9 @@ void GBAHardwareClear(struct GBACartridgeHardware* hw) { } void GBAHardwareGPIOWrite(struct GBACartridgeHardware* hw, uint32_t address, uint16_t value) { + if (!hw->gpioBase) { + return; + } switch (address) { case GPIO_REG_DATA: hw->pinState &= ~hw->direction;