summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2014-12-30 23:37:26 +0000
committerPádraig Brady <P@draigBrady.com>2014-12-30 23:42:03 +0000
commit55cda57aa2efe89cee367f73fb4b0ce55a1c8c18 (patch)
tree0d71e10de3de737a267c6bedf2dfb897bacc1aa1 /lib
parent7177237ead4c6080705129e6ec3c3a9e9eef2f68 (diff)
downloadgnulib-55cda57aa2efe89cee367f73fb4b0ce55a1c8c18.tar.gz
xstrtol: ensure errno is reset
Since commit 3bf75404, on 26-09-1998, errno may not have been reset. Noticed with a spurious coreutils test failure on Darwin 14.0.0. * lib/xstrtol.c (__xstrtol): Always reset errno before returning.
Diffstat (limited to 'lib')
-rw-r--r--lib/xstrtol.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/xstrtol.c b/lib/xstrtol.c
index 544a74aa1c..7ab864bb52 100644
--- a/lib/xstrtol.c
+++ b/lib/xstrtol.c
@@ -97,6 +97,8 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
p = (ptr ? ptr : &t_ptr);
+ errno = 0;
+
if (! TYPE_SIGNED (__strtol_t))
{
const char *q = s;
@@ -107,7 +109,6 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
return LONGINT_INVALID;
}
- errno = 0;
tmp = __strtol (s, p, strtol_base);
if (*p == s)