mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
Shell: fix crash when using cd -
and OLDPWD is null
This commit is contained in:
parent
3d4935a223
commit
af6948afe0
1 changed files with 2 additions and 0 deletions
|
@ -85,6 +85,8 @@ static int sh_cd(int argc, char** argv)
|
|||
} else {
|
||||
if (strcmp(argv[1], "-") == 0) {
|
||||
char* oldpwd = getenv("OLDPWD");
|
||||
if (oldpwd == nullptr)
|
||||
return 1;
|
||||
size_t len = strlen(oldpwd);
|
||||
ASSERT(len + 1 <= PATH_MAX);
|
||||
memcpy(pathbuf, oldpwd, len + 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue