diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/POSIX/fd.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/runtime/POSIX/fd.c b/runtime/POSIX/fd.c index cfd2622f..35d0d315 100644 --- a/runtime/POSIX/fd.c +++ b/runtime/POSIX/fd.c @@ -1351,9 +1351,15 @@ char *getcwd(char *buf, size_t size) { } if (!buf) { - if (!size) - size = 1024; + size = 1024; // typically PATH_MAX buf = malloc(size); + if (!buf) { + errno = ENOMEM; + return NULL; + } + } else if (!size) { + errno = EINVAL; + return NULL; } buf = __concretize_ptr(buf); |