]> Sergey Matveev's repositories - nnn.git/commitdiff
Merge pull request #1650 from leo-arch/master
authorArun <engineerarun@gmail.com>
Thu, 18 May 2023 20:27:34 +0000 (01:57 +0530)
committerGitHub <noreply@github.com>
Thu, 18 May 2023 20:27:34 +0000 (01:57 +0530)
Fix crash when PWD is set to empty string

src/nnn.c

index 71ae7a010202afd262ebc644ce1d3efb3e8b5759..6bd82d2d2dd81f7fc43544b7f4191a1733bbb69b 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -8713,7 +8713,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 */