From e717a16398890398968b96a90ecab2e9c355786c Mon Sep 17 00:00:00 2001 From: mart0258 Date: Thu, 12 Aug 2010 06:27:06 +0000 Subject: [PATCH] Fix crash (loadstate on missing file) and memory leak (failed to write screenshot) --- src/state.cpp | 2 +- src/video.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/state.cpp b/src/state.cpp index 0de6e636..ef8b5db5 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -917,7 +917,7 @@ void FCEUI_LoadState(const char *fname) { FCEUI_MakeBackupMovie(false); //Backup the movie before the contents get altered, but do not display messages } - if (!file_exists(fname) && fname != NULL) + if (fname != NULL && !file_exists(fname)) { loadStateFailed = 1; return; // state doesn't exist; exit cleanly diff --git a/src/video.cpp b/src/video.cpp index 67c9ba43..de06b33f 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -587,6 +587,7 @@ int SaveSnapshot(void) if(!(pp=FCEUD_UTF8fopen(fn,"wb"))) { free(fn); + free(compmem); return 0; } free(fn); @@ -681,6 +682,7 @@ int SaveSnapshot(char fileName[512]) if(!(pp=FCEUD_UTF8fopen(fileName,"wb"))) { + free(compmem); return 0; }