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