mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-14 22:45:38 +08:00
Fix non-standard getcwd() invocation
The POSIX standard specifies that a buffer should be supplied to getcwd(), not doing so is undefined (or rather, platform-defined) behavior. This was causing the getcwd errors on illumos (though not seen on Solaris 11) reported in #3340 Closes #3340 (cherry picked from commit b495c68f28b44e0d9065c7cd2d73712b8283a4c3)
This commit is contained in:
parent
67e3bac583
commit
c8425f832c
@ -137,18 +137,14 @@ bool wreaddir_for_dirs(DIR *dir, wcstring *out_name) {
|
||||
}
|
||||
|
||||
const wcstring wgetcwd() {
|
||||
wcstring retval;
|
||||
|
||||
char *res = getcwd(NULL, 0);
|
||||
char cwd[NAME_MAX];
|
||||
char *res = getcwd(cwd, sizeof(cwd));
|
||||
if (res) {
|
||||
retval = str2wcstring(res);
|
||||
free(res);
|
||||
} else {
|
||||
debug(0, _(L"getcwd() failed with errno %d/%s"), errno, strerror(errno));
|
||||
retval = wcstring();
|
||||
return str2wcstring(res);
|
||||
}
|
||||
|
||||
return retval;
|
||||
debug(0, _(L"getcwd() failed with errno %d/%s"), errno, strerror(errno));
|
||||
return wcstring();
|
||||
}
|
||||
|
||||
int wchdir(const wcstring &dir) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user