about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHerman ten Brugge <hermantenbrugge@home.nl>2018-06-15 17:35:17 +0000
committerJoseph Myers <joseph@codesourcery.com>2018-06-15 17:35:17 +0000
commitb0debe14fcfe690eee8b5e693554dd258603805d (patch)
treec393efa15c55dba3efa488b10a6bd861f3372791
parent14beef7575099f6373f9a45b4656f1e3675f7372 (diff)
downloadglibc-b0debe14fcfe690eee8b5e693554dd258603805d.tar.gz
glibc-b0debe14fcfe690eee8b5e693554dd258603805d.tar.xz
glibc-b0debe14fcfe690eee8b5e693554dd258603805d.zip
Fix sign of NaN returned by strtod (bug 23007).
As reported in bug 23007, strtod ignores any sign in the input string
in the case of a NaN result.  Thes patch fixes this.

Tested for x86_64 (in conjunction with tests to be added separately).

	[BZ #23007]
	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Return NaN of
	appropriate sign.
-rw-r--r--ChangeLog6
-rw-r--r--stdlib/strtod_l.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6cf157acb3..c0f58f5214 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-06-15  Herman ten Brugge  <hermantenbrugge@home.nl>
+
+	[BZ #23007]
+	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Return NaN of
+	appropriate sign.
+
 2018-06-14  Florian Weimer  <fweimer@redhat.com>
 
 	[BZ #23290]
diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index a09b093fce..cbff18b49d 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -678,7 +678,7 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	  if (endptr != NULL)
 	    *endptr = (STRING_TYPE *) cp;
 
-	  return retval;
+	  return negative ? -retval : retval;
 	}
 
       /* It is really a text we do not recognize.  */