Return the correct errno from getcwd() even if free() or closedir()
overwrites it. This actually showed up when running under an old kernel when free() called the madvise() stub which set errno, causing getcwd() to return EOPNOTSUPP instead of ERANGE.
This commit is contained in:
parent
7cb9d73216
commit
4773010d2f
@ -268,10 +268,14 @@ getcwd(pt, size)
|
||||
errno = save_errno ? save_errno : ENOENT;
|
||||
/* FALLTHROUGH */
|
||||
err:
|
||||
save_errno = errno;
|
||||
|
||||
if (ptsize)
|
||||
free(pt);
|
||||
if (dir)
|
||||
(void) closedir(dir);
|
||||
free(up);
|
||||
|
||||
errno = save_errno;
|
||||
return (NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user