all repos — mgba @ e82c9aadea0133744f6f6c309312f44caaa51eb0

mGBA Game Boy Advance Emulator

GB Memory: Fix out of bounds memory condition in GBView8/GBPatch8
Jeffrey Pfau jeffrey@endrift.com
Fri, 16 Sep 2016 19:48:13 -0700
commit

e82c9aadea0133744f6f6c309312f44caaa51eb0

parent

a71007267d684ff85249be0b6947d6a3e7ce9678

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

jump to
M src/gb/memory.csrc/gb/memory.c

@@ -263,7 +263,7 @@ case GB_REGION_CART_BANK1 + 3:

if (segment < 0) { return memory->romBank[address & (GB_SIZE_CART_BANK0 - 1)]; } else { - if ((size_t) segment * GB_SIZE_CART_BANK0 > memory->romSize) { + if ((size_t) segment * GB_SIZE_CART_BANK0 >= memory->romSize) { return 0xFF; } return memory->rom[(address & (GB_SIZE_CART_BANK0 - 1)) + segment * GB_SIZE_CART_BANK0];

@@ -501,7 +501,7 @@ if (segment < 0) {

oldValue = memory->romBank[address & (GB_SIZE_CART_BANK0 - 1)]; memory->romBank[address & (GB_SIZE_CART_BANK0 - 1)] = value; } else { - if ((size_t) segment * GB_SIZE_CART_BANK0 > memory->romSize) { + if ((size_t) segment * GB_SIZE_CART_BANK0 >= memory->romSize) { return; } oldValue = memory->rom[(address & (GB_SIZE_CART_BANK0 - 1)) + segment * GB_SIZE_CART_BANK0];