Fix some memory leak.
This commit is contained in:
parent
8ea607e1c7
commit
030740ee34
|
@ -663,12 +663,12 @@ const char* FindConfigFile(const char *name)
|
||||||
|
|
||||||
struct stat s;
|
struct stat s;
|
||||||
std::string homeDirTmp = get_xdg_user_config_home() + DOT_DIR;
|
std::string homeDirTmp = get_xdg_user_config_home() + DOT_DIR;
|
||||||
homeDir = strdup(homeDirTmp.c_str());
|
char *fullDir = (char *)homeDirTmp.c_str();
|
||||||
if (stat(homeDir, &s) == -1 || !S_ISDIR(s.st_mode))
|
if (stat(fullDir, &s) == -1 || !S_ISDIR(s.st_mode))
|
||||||
mkdir(homeDir, 0755);
|
mkdir(fullDir, 0755);
|
||||||
|
|
||||||
if (homeDir) {
|
if (fullDir) {
|
||||||
sprintf(path, "%s%c%s", homeDir, FILE_SEP, name);
|
sprintf(path, "%s%c%s", fullDir, FILE_SEP, name);
|
||||||
if (FileExists(path))
|
if (FileExists(path))
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -369,7 +369,7 @@ FILE* sdlFindFile(const char* name)
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (homeDir) {
|
if (homeDataDir) {
|
||||||
fprintf(stdout, "Searching home directory: %s\n", homeDataDir);
|
fprintf(stdout, "Searching home directory: %s\n", homeDataDir);
|
||||||
sprintf(path, "%s%c%s", homeDataDir, FILE_SEP, name);
|
sprintf(path, "%s%c%s", homeDataDir, FILE_SEP, name);
|
||||||
f = fopen(path, "r");
|
f = fopen(path, "r");
|
||||||
|
|
Loading…
Reference in New Issue