Skip to content

Commit

Permalink
Fix getpwd() for non-glibc systems.
Browse files Browse the repository at this point in the history
In commit e048cdd I changed getpwd() to no longer call savestr(),
choosing to keep the path in the already available buffer, but neglected
to make the buffer available after the function returned.

Reported by Martijn Dekker.

Test case:

  pwd -P
  • Loading branch information
hvdijk committed Apr 12, 2024
1 parent 56a0899 commit a95a1c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ getpwd(int flags)
if (dir)
return dir;
#else
char buf[PATH_MAX];
static char buf[PATH_MAX];

if (getcwd(buf, sizeof(buf)))
return buf;
Expand Down

0 comments on commit a95a1c2

Please sign in to comment.