diff --git a/src/cmdlib.cpp b/src/cmdlib.cpp index 36a900709..96aca06a1 100644 --- a/src/cmdlib.cpp +++ b/src/cmdlib.cpp @@ -1004,7 +1004,8 @@ void ScanDirectory(TArray &list, const char *dirpath) void ScanDirectory(TArray &list, const char *dirpath) { - const char **argv[] = {dirpath, NULL }; + char * const argv[] = {new char[strlen(dirpath)+1], NULL }; + memcpy(argv[0], dirpath, strlen(dirpath)+1); FTS *fts; FTSENT *ent; @@ -1012,6 +1013,7 @@ void ScanDirectory(TArray &list, const char *dirpath) if (fts == NULL) { I_Error("Failed to start directory traversal: %s\n", strerror(errno)); + delete[] argv[0]; return; } while ((ent = fts_read(fts)) != NULL) @@ -1037,5 +1039,6 @@ void ScanDirectory(TArray &list, const char *dirpath) } } fts_close(fts); + delete[] argv[0]; } #endif diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 8a491f595..c48d72e8f 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -1077,7 +1077,7 @@ static FString GetCachePath() FSRef folder; if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) && - noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX)) + noErr == FSRefMakePath(&folder, (UInt8*)path.GetChars(), PATH_MAX)) { path = pathstr; }