diff options
author | harry <hrosen2016@gmail.com> | 2022-08-04 12:06:31 +0300 |
---|---|---|
committer | zeromus <zeromus@users.noreply.github.com> | 2022-08-05 04:15:59 +0300 |
commit | 44c8e15503f8596e1b084df47ff660525802fc91 (patch) | |
tree | 6def78bf2ae4003650ce6745d88f0f2c47b21034 | |
parent | 02bf3dbb4dbc611d02e465f9c18ec6f35d8c80f5 (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.cpp | 2 |
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
|