shithub: choc

Download patch

ref: a378d0288a77ef8efff439c5e250e82b03e2c502
parent: 7d1ad9f2759668c45fd25a46d239c923ff6cdf82
author: Fabian Greffrath <fabian@greffrath.com>
date: Wed Mar 10 15:19:06 EST 2021

append a path delimiter to the default config dir on Windows (#1357)

* append a path delimiter to the default config dir on Windows

https://www.doomworld.com/forum/topic/86366-chocolate-doom/?page=28&tab=comments#comment-2272910

* avoid leaking the string allocated by M_DirName()

--- a/src/m_config.c
+++ b/src/m_config.c
@@ -2273,6 +2273,9 @@
 
 static char *GetDefaultConfigDir(void)
 {
+    char *result;
+    char *copy;
+
 #if !defined(_WIN32) || defined(_WIN32_WCE)
 
     // Configuration settings are stored in an OS-appropriate path
@@ -2280,9 +2283,6 @@
     // ~/.local/share/chocolate-doom.  On Windows, we behave like
     // Vanilla Doom and save in the current directory.
 
-    char *result;
-    char *copy;
-
     result = SDL_GetPrefPath("", PACKAGE_TARNAME);
     if (result != NULL)
     {
@@ -2291,7 +2291,11 @@
         return copy;
     }
 #endif /* #ifndef _WIN32 */
-    return M_DirName(myargv[0]);
+
+    result = M_DirName(myargv[0]);
+    copy = M_StringJoin(result, DIR_SEPARATOR_S, NULL);
+    free(result);
+    return copy;
 }
 
 //