Cheats: Fixed crash when creating a custom memory cheat with an address above $FFFF

This commit is contained in:
Souryo 2017-08-08 13:01:55 -04:00
parent f536f62dd1
commit 6d768cda0a
2 changed files with 9 additions and 0 deletions

View File

@ -85,6 +85,11 @@ CodeInfo CheatManager::GetPARCodeInfo(uint32_t parCode)
void CheatManager::AddCode(CodeInfo &code)
{
if(code.IsRelativeAddress) {
if(code.Address > 0xFFFF) {
//Invalid cheat, ignore it
return;
}
if(_relativeCheatCodes[code.Address] == nullptr) {
_relativeCheatCodes[code.Address].reset(new vector<CodeInfo>());
}

View File

@ -123,6 +123,10 @@ namespace Mesen.GUI.Forms.Cheats
if(!UInt32.TryParse(txtAddress.Text, System.Globalization.NumberStyles.AllowHexSpecifier, null, out val)) {
return false;
}
if(radRelativeAddress.Checked && val > 0xFFFF) {
//Do not allow cheats outside the 0-0xFFFF range in relative addressing mode
return false;
}
if(!Byte.TryParse(txtValue.Text, System.Globalization.NumberStyles.AllowHexSpecifier, null, out byteVal)) {
return false;