getcwd: work around mingw bug
[gnulib.git] / lib / getcwd-lgpl.c
index 53c5562..2761422 100644 (file)
@@ -45,7 +45,14 @@ rpl_getcwd (char *buf, size_t size)
 
   /* Handle single size operations.  */
   if (buf)
-    return getcwd (buf, size);
+    {
+      if (!size)
+        {
+          errno = EINVAL;
+          return NULL;
+        }
+      return getcwd (buf, size);
+    }
 
   if (size)
     {