Fix crash when PWD is set to empty string

nnn crashes when PWD is set to empty string: `PWD="" nnn`
This commit is contained in:
leo-arch 2023-05-14 20:12:04 +00:00 committed by GitHub
parent aaf60b93d7
commit 4babedc3e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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 */