c-strtod: when ENDPTR is non-NULL, set *ENDPTR in new failure path
authorJim Meyering <meyering@redhat.com>
Fri, 23 Jan 2009 15:21:57 +0000 (16:21 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 23 Jan 2009 16:33:01 +0000 (17:33 +0100)
* lib/c-strtod.c (C_STRTOD) [LC_ALL_MASKC]: Ensure that when
ENDPTR is non-NULL, *ENDPTR is set to NPTR upon failure.

ChangeLog
lib/c-strtod.c

index ca37425..66a6632 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-23  Jim Meyering  <meyering@redhat.com>
+
+       c-strtod: when ENDPTR is non-NULL, set *ENDPTR in new failure path
+       * lib/c-strtod.c (C_STRTOD) [LC_ALL_MASKC]: Ensure that when
+       ENDPTR is non-NULL, *ENDPTR is set to NPTR upon failure.
+
 2009-01-23  Simon Josefsson  <simon@josefsson.org>
 
        * lib/version-etc.c: Add emit_bug_reporting_address, inspired by
index 3d0fae9..77e5aaf 100644 (file)
@@ -72,7 +72,11 @@ C_STRTOD (char const *nptr, char **endptr)
 
   locale_t locale = c_locale ();
   if (!locale)
-    return 0; /* errno is set here */
+    {
+      if (endptr)
+        *endptr = nptr;
+      return 0; /* errno is set here */
+    }
 
   r = STRTOD_L (nptr, endptr, locale);