From 44c8e15503f8596e1b084df47ff660525802fc91 Mon Sep 17 00:00:00 2001 From: harry Date: Thu, 4 Aug 2022 05:06:31 -0400 Subject: [PATCH] Fix for small memory leak in GetBackupFileName(). strdup allocates memory and returns a char pointer to it. However std::string allocates its own memory already. Since FCEU_MakeFName returns a std::string already, there is no reason to use strdup in between the assignment of one std::string to another. --- src/state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state.cpp b/src/state.cpp index 503622b1..a40e665e 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -1103,7 +1103,7 @@ string GetBackupFileName() string filename; int x; - filename = strdup(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str()); //Generate normal savestate filename + filename = FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0); //Generate normal savestate filename x = filename.find_last_of("."); //Find last dot filename = filename.substr(0,x); //Chop off file extension filename.append(".bak.fc0"); //add .bak