From: leo-arch Date: Sun, 14 May 2023 20:12:04 +0000 (+0000) Subject: Fix crash when PWD is set to empty string X-Git-Tag: v4.9~15^2 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4babedc3e4a6ea1fe0d5667fd736febe1fce9211;p=nnn.git Fix crash when PWD is set to empty string nnn crashes when PWD is set to empty string: `PWD="" nnn` --- diff --git a/src/nnn.c b/src/nnn.c index 46e95c5f..2878a149 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -8716,7 +8716,7 @@ int main(int argc, char *argv[]) /* Start in the current directory */ char *startpath = getenv("PWD"); - initpath = startpath ? xstrdup(startpath) : getcwd(NULL, 0); + initpath = (startpath && *startpath) ? xstrdup(startpath) : getcwd(NULL, 0); if (!initpath) initpath = "/"; } else { /* Open a file */