mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:57:35 +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 {
|
} else {
|
||||||
if (strcmp(argv[1], "-") == 0) {
|
if (strcmp(argv[1], "-") == 0) {
|
||||||
char* oldpwd = getenv("OLDPWD");
|
char* oldpwd = getenv("OLDPWD");
|
||||||
|
if (oldpwd == nullptr)
|
||||||
|
return 1;
|
||||||
size_t len = strlen(oldpwd);
|
size_t len = strlen(oldpwd);
|
||||||
ASSERT(len + 1 <= PATH_MAX);
|
ASSERT(len + 1 <= PATH_MAX);
|
||||||
memcpy(pathbuf, oldpwd, len + 1);
|
memcpy(pathbuf, oldpwd, len + 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue