From 672406258139e68bed12124470625b5831e3dc46 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Wed, 30 Dec 2020 15:20:34 -0500 Subject: [PATCH] Fixed NULL check for SPostSave function pointer. Initialized SPreSave and SPostSave pointers to NULL to ensure their initial state is consistent. Also, init FCEU_state_loading_old_format to false as it is always better to have an initial state defined than none at all. --- src/state.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/state.cpp b/src/state.cpp index 718e3a6d..778251d6 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -61,14 +61,14 @@ using namespace std; -static void (*SPreSave)(void); -static void (*SPostSave)(void); +static void (*SPreSave)(void) = NULL; +static void (*SPostSave)(void) = NULL; static int SaveStateStatus[10]; static int StateShow; //tells the save system innards that we're loading the old format -bool FCEU_state_loading_old_format; +bool FCEU_state_loading_old_format = false; char lastSavestateMade[2048]; //Stores the filename of the last savestate made (needed for UndoSavestate) bool undoSS = false; //This will be true if there is lastSavestateMade, it was made since ROM was loaded, a backup state for lastSavestateMade exists @@ -413,7 +413,7 @@ bool FCEUSS_SaveMS(EMUFILE* outstream, int compressionLevel) if(SPreSave) SPreSave(); totalsize+=WriteStateChunk(os,0x10,SFMDATA); - if(SPreSave) SPostSave(); + if(SPostSave) SPostSave(); //save the length of the file int len = memory_savestate.size();