From 4babedc3e4a6ea1fe0d5667fd736febe1fce9211 Mon Sep 17 00:00:00 2001 From: leo-arch Date: Sun, 14 May 2023 20:12:04 +0000 Subject: [PATCH] Fix crash when PWD is set to empty string nnn crashes when PWD is set to empty string: `PWD="" nnn` --- src/nnn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */