From c0cce90e601c1948ba82bcfeda35093801712b11 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 15:34:18 +0100 Subject: [PATCH] properly handle getcwd error in IdentifyVersion if getcwd fails, the buffer contents will be undefined so we shall just overwrite it again with "." --- src/d_main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index c46ef0c44..f37d70a2c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1186,17 +1186,13 @@ static void IdentifyVersion(void) #endif char tempsrb2path[256] = "."; - getcwd(tempsrb2path, 256); + if (getcwd(tempsrb2path, 256) == NULL) + strcpy(tempsrb2path, "."); // get the current directory (possible problem on NT with "." as current dir) if (!srb2waddir) { - if (tempsrb2path[0]) - srb2waddir = tempsrb2path; - else - { - srb2waddir = "."; - } + srb2waddir = tempsrb2path; } #if (1) // reduce the amount of findfile by only using full cwd in this func