[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] getcwd: work around mingw bug
From: |
Eric Blake |
Subject: |
[PATCH] getcwd: work around mingw bug |
Date: |
Wed, 25 May 2011 15:17:07 -0600 |
mingw getcwd(buf, 0) fails with ERANGE, instead of the required
EINVAL. Since we're already replacing getcwd on mingw, the
workaround is trivial.
* lib/getcwd-lgpl.c (rpl_getcwd): Guarantee correct error.
Reported by Matthias Bolte.
Signed-off-by: Eric Blake <address@hidden>
---
It took me much less time to write this patch than to test it...
ChangeLog | 6 ++++++
lib/getcwd-lgpl.c | 9 ++++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 390d4e8..2e8dbe9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-25 Eric Blake <address@hidden>
+
+ getcwd: work around mingw bug
+ * lib/getcwd-lgpl.c (rpl_getcwd): Guarantee correct error.
+ Reported by Matthias Bolte.
+
2011-05-24 Paul Eggert <address@hidden>
test-intprops: disable -Wtype-limits diagnostics
diff --git a/lib/getcwd-lgpl.c b/lib/getcwd-lgpl.c
index 53c5562..2761422 100644
--- a/lib/getcwd-lgpl.c
+++ b/lib/getcwd-lgpl.c
@@ -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)
{
--
1.7.4.4