commit 4babedc3e4a6ea1fe0d5667fd736febe1fce9211
parent aaf60b93d741ffff211902a10a159434629bbdb9
Author: leo-arch <leonardoabramovich2@gmail.com>
Date: Sun, 14 May 2023 20:12:04 +0000
Fix crash when PWD is set to empty string
nnn crashes when PWD is set to empty string: `PWD="" nnn`
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git 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 */