mirror of https://github.com/mgba-emu/mgba.git
Core: Check for null when autoloading/saving cheats
This commit is contained in:
parent
7ae9117930
commit
952c883755
|
@ -627,6 +627,9 @@ void mCheatAutosave(struct mCheatDevice* device) {
|
|||
if (!device->autosave) {
|
||||
return;
|
||||
}
|
||||
if (!device->p->dirs.cheats) {
|
||||
return;
|
||||
}
|
||||
struct VFile* vf = mDirectorySetOpenSuffix(&device->p->dirs, device->p->dirs.cheats, ".cheats", O_WRONLY | O_CREAT | O_TRUNC);
|
||||
if (!vf) {
|
||||
return;
|
||||
|
|
|
@ -243,14 +243,16 @@ bool mCoreAutoloadPatch(struct mCore* core) {
|
|||
}
|
||||
|
||||
bool mCoreAutoloadCheats(struct mCore* core) {
|
||||
bool success = true;
|
||||
bool success = !!core->dirs.cheats;
|
||||
int cheatAuto;
|
||||
if (!mCoreConfigGetIntValue(&core->config, "cheatAutoload", &cheatAuto) || cheatAuto) {
|
||||
if (success && (!mCoreConfigGetIntValue(&core->config, "cheatAutoload", &cheatAuto) || cheatAuto)) {
|
||||
struct VFile* vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.cheats, ".cheats", O_RDONLY);
|
||||
if (vf) {
|
||||
struct mCheatDevice* device = core->cheatDevice(core);
|
||||
success = mCheatParseFile(device, vf);
|
||||
vf->close(vf);
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
if (!mCoreConfigGetIntValue(&core->config, "cheatAutosave", &cheatAuto) || cheatAuto) {
|
||||
|
|
Loading…
Reference in New Issue