Core: Check for null when autoloading/saving cheats

This commit is contained in:
Vicki Pfau 2024-10-04 17:13:43 -07:00
parent 7ae9117930
commit 952c883755
2 changed files with 7 additions and 2 deletions

View File

@ -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;

View File

@ -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) {