save some things that weren't saved but should have been
[pcsx_rearmed.git] / libpcsxcore / cheat.c
index a016aee..e0cf411 100644 (file)
@@ -19,6 +19,7 @@
 #include "psxcommon.h"
 #include "r3000a.h"
 #include "psxmem.h"
+#include "misc.h"
 
 #include "cheat.h"
 
@@ -340,7 +341,6 @@ int AddCheat(const char *descr, char *code) {
                }
        }
 
-       Cheats[NumCheats].Descr = strdup(descr[0] ? descr : _("(Untitled)"));
        Cheats[NumCheats].Enabled = 0;
        Cheats[NumCheats].WasEnabled = 0;
        Cheats[NumCheats].First = NumCodes;
@@ -392,6 +392,7 @@ int AddCheat(const char *descr, char *code) {
                return -1;
        }
 
+       Cheats[NumCheats].Descr = strdup(descr[0] ? descr : _("(Untitled)"));
        NumCheats++;
        return 0;
 }
@@ -400,6 +401,7 @@ void RemoveCheat(int index) {
        assert(index >= 0 && index < NumCheats);
 
        free(Cheats[index].Descr);
+       Cheats[index].Descr = NULL;
 
        while (index < NumCheats - 1) {
                Cheats[index] = Cheats[index + 1];