summaryrefslogtreecommitdiff
path: root/LibC/unistd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LibC/unistd.cpp')
-rw-r--r--LibC/unistd.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/LibC/unistd.cpp b/LibC/unistd.cpp
index 71a57a290e..e0123fe63a 100644
--- a/LibC/unistd.cpp
+++ b/LibC/unistd.cpp
@@ -6,6 +6,7 @@
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <Kernel/Syscall.h>
@@ -186,6 +187,10 @@ int chdir(const char* path)
char* getcwd(char* buffer, size_t size)
{
+ if (!buffer) {
+ size = size ? size : PATH_MAX;
+ buffer = (char*)malloc(size);
+ }
int rc = syscall(SC_getcwd, buffer, size);
__RETURN_WITH_ERRNO(rc, buffer, nullptr);
}