foxygit / doom Log in
commit a378d0288a77ef8efff439c5e250e82b03e2c502
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Wed Mar 10 20:19:06 2021 +0100
Commit:     GitHub <noreply@github.com>
CommitDate: Wed Mar 10 20:19:06 2021 +0100

    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()
---
 src/m_config.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/m_config.c b/src/m_config.c
index 20a886e7..c8971595 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -2273,6 +2273,9 @@ float M_GetFloatVariable(const char *name)

 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 @@ static char *GetDefaultConfigDir(void)
     // ~/.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 @@ static char *GetDefaultConfigDir(void)
         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;
 }

 //