Fix minor potential memory leak.

This commit is contained in:
Ian Rees
2017-03-21 11:21:24 +13:00
committed by wmayer
parent eb608e818e
commit ffc4564c84

View File

@@ -2285,12 +2285,12 @@ std::string Application::FindHomePath(const char* call)
char *buf;
_NSGetExecutablePath(NULL, &sz); //function only returns "sz" if first arg is to small to hold value
buf = (char*) malloc(++sz);
buf = new char[++sz];
if (_NSGetExecutablePath(buf, &sz) == 0) {
char resolved[PATH_MAX];
char* path = realpath(buf, resolved);
free(buf);
delete [] buf;
if (path) {
std::string Call(resolved), TempHomePath;
@@ -2300,6 +2300,8 @@ std::string Application::FindHomePath(const char* call)
TempHomePath.assign(TempHomePath,0,pos+1);
return TempHomePath;
}
} else {
delete [] buf;
}
return call; // error