mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
Shell: fix crash when using cd -
and OLDPWD is null
This commit is contained in:
parent
3d4935a223
commit
af6948afe0
Notes:
sideshowbarker
2024-07-19 12:07:54 +09:00
Author: https://github.com/seven1m Commit: https://github.com/SerenityOS/serenity/commit/af6948afe00 Pull-request: https://github.com/SerenityOS/serenity/pull/554
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
Reference in a new issue