From f63e20501f73fd63a484f7a1456c35ece2e16bd3 Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 23 Apr 2013 00:17:00 +0000 Subject: [PATCH] NDSSystem: - Fix potential crashing bug. --- desmume/src/NDSSystem.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index c91bc5b20..7213e2aca 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -165,10 +165,12 @@ void NDS_DeInit(void) { gpu3D->NDS_3D_Close(); WIFI_DeInit(); - if (cheats) - delete cheats; - if (cheatSearch) - delete cheatSearch; + + delete cheats; + cheats = NULL; + + delete cheatSearch; + cheatSearch = NULL; #ifdef HAVE_JIT arm_jit_close(); @@ -615,10 +617,13 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi strcat(buf, ".dsv"); // DeSmuME memory card :) MMU_new.backupDevice.load_rom(buf); - memset(buf, 0, MAX_PATH); - path.getpathnoext(path.CHEATS, buf); - strcat(buf, ".dct"); // DeSmuME cheat :) - cheats->init(buf); + if (cheats != NULL) + { + memset(buf, 0, MAX_PATH); + path.getpathnoext(path.CHEATS, buf); + strcat(buf, ".dct"); // DeSmuME cheat :) + cheats->init(buf); + } NDS_Reset();