Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/fceux.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorharry <hrosen2016@gmail.com>2022-08-04 12:06:31 +0300
committerzeromus <zeromus@users.noreply.github.com>2022-08-05 04:15:59 +0300
commit44c8e15503f8596e1b084df47ff660525802fc91 (patch)
tree6def78bf2ae4003650ce6745d88f0f2c47b21034
parent02bf3dbb4dbc611d02e465f9c18ec6f35d8c80f5 (diff)
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.
-rw-r--r--src/state.cpp2
1 files changed, 1 insertions, 1 deletions
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