GBA: Handle out-of-bounds I/O access

This commit is contained in:
Jeffrey Pfau 2015-05-08 01:48:22 -07:00
parent ebcb344d64
commit 78db3e1a74
2 changed files with 9 additions and 0 deletions

View File

@ -46,6 +46,7 @@ Bugfixes:
- Util: Fix a null-pointer issue when attempting to delete a key
- SDL: Allocate properly sized input maps
- ARM7: Handle writeback for PC in addressing modes 2 and 3
- GBA: Handle out-of-bounds I/O access
Misc:
- Qt: Show multiplayer numbers in window title
- Qt: Handle saving input settings better

View File

@ -489,6 +489,10 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
break;
default:
GBALog(gba, GBA_LOG_STUB, "Stub I/O register write: %03x", address);
if (address >= REG_MAX) {
GBALog(gba, GBA_LOG_GAME_ERROR, "Write to unused I/O register: %03X", address);
return;
}
break;
}
}
@ -643,6 +647,10 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) {
break;
default:
GBALog(gba, GBA_LOG_STUB, "Stub I/O register read: %03x", address);
if (address >= REG_MAX) {
GBALog(gba, GBA_LOG_GAME_ERROR, "Read from unused I/O register: %03X", address);
return 0; // TODO: Reuse LOAD_BAD
}
break;
}
return gba->memory.io[address >> 1];