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.

This commit is contained in:
harry 2022-08-04 05:06:31 -04:00 committed by zeromus
parent 02bf3dbb4d
commit 44c8e15503
1 changed files with 1 additions and 1 deletions

View File

@ -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