From e934ad609d3639152324a4211857d87f228cf938 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Thu, 16 Apr 2015 12:43:07 -0400 Subject: When strtod sets errno, force the numeric value to zero. --- node.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'node.c') diff --git a/node.c b/node.c index f19354e6..1741a13b 100644 --- a/node.c +++ b/node.c @@ -138,11 +138,20 @@ r_force_number(NODE *n) ptr++; *cpend = save; finish: - if (errno == 0 && ptr == cpend) { - n->flags |= newflags; - n->flags |= NUMCUR; + if (errno == 0) { + if (ptr == cpend) { + n->flags |= newflags; + n->flags |= NUMCUR; + } + /* else keep the leading numeric value without updating flags */ } else { errno = 0; + /* + * N.B. For subnormal values, strtod may return the + * floating-point representation while setting errno to ERANGE. + * We force the numeric value to 0 in such cases. + */ + n->numbr = 0; } return n; -- cgit v1.2.3