[fix Duplicate the fileName so that the memory isn't statically reallocated
@@ -498,7 +498,7 @@ int main(int argc, char* args[])
char* dirc = strdup(pathBuf);
char* basec = strdup(pathBuf);
// This sets the filename used.
- fileName = basename(dirc);
+ fileName = strdup(basename(dirc));
BASEPATH_set(dirname(basec));
free(dirc);
free(basec);
@@ -537,6 +537,10 @@ int main(int argc, char* args[])
strcpy(pathBuf, !autoResolve ? fileName : mainFileName);
}
+ if (fileName != NULL) {
+ free(fileName);
+ }
+
// The basepath is incorporated later, so we pass the basename version to this method.
gameFile = ENGINE_readFile(&engine, pathBuf, &gameFileLength);
if (gameFile == NULL) {
