From 51e478e66a27c5f7021274b84fa3d24c2261c2a5 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 1 Sep 2014 23:20:20 +0000 Subject: [PATCH] fix bugs from r4926 (off-by-one error in out-of-range rom-reading check). possibly broke the last u32 in the rom. fixes bug #1406 (phantasy star 0 CHS translation black screen freeze) --- desmume/src/NDSSystem.cpp | 2 +- desmume/src/addons/slot1comp_rom.cpp | 2 +- desmume/src/windows/main.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 0ae486bf7..06ca3ee46 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -541,7 +541,7 @@ u32 GameInfo::readROM(u32 pos) } else { - if(pos + 4 >= romsize) + if(pos + 4 > romsize) { printf("Panic! GameInfo reading out of buffer!\n"); exit(-1); diff --git a/desmume/src/addons/slot1comp_rom.cpp b/desmume/src/addons/slot1comp_rom.cpp index 549cafb38..50415d9c1 100644 --- a/desmume/src/addons/slot1comp_rom.cpp +++ b/desmume/src/addons/slot1comp_rom.cpp @@ -66,7 +66,7 @@ u32 Slot1Comp_Rom::read() //if (address > gameInfo.header.endROMoffset) // ... the cart hardware doesnt know anything about the rom header. if it has a totally bogus endROMoffset, the cart will probably work just fine. and, the +4 is missing anyway: //3. this is better: it just allows us to read 0xFF anywhere we dont have rom data. forget what the header says - if(address+4 >= gameInfo.romsize) + if(address+4 > gameInfo.romsize) { DEBUG_Notify.ReadBeyondEndOfCart(address,gameInfo.romsize); return 0xFFFFFFFF; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 669eae9b3..0b5fd8505 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -3090,6 +3090,7 @@ int _main() } //disable wacky stylus stuff + //TODO - we are obliged to call GlobalDeleteAtom GlobalAddAtom(MICROSOFT_TABLETPENSERVICE_PROPERTY); SetProp(MainWindow->getHWnd(),MICROSOFT_TABLETPENSERVICE_PROPERTY,(HANDLE)( TABLET_DISABLE_PRESSANDHOLD |