about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/unistd/getcwd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/unistd/getcwd.c b/src/unistd/getcwd.c
index 103fbbb5..f407ffe0 100644
--- a/src/unistd/getcwd.c
+++ b/src/unistd/getcwd.c
@@ -6,10 +6,10 @@
 
 char *getcwd(char *buf, size_t size)
 {
-	char tmp[PATH_MAX];
+	char tmp[buf ? 1 : PATH_MAX];
 	if (!buf) {
 		buf = tmp;
-		size = PATH_MAX;
+		size = sizeof tmp;
 	} else if (!size) {
 		errno = EINVAL;
 		return 0;