index fe6c6f8a05a51fc3db423d99663d3d35256b63d3..1c4f9ac04e6d18bb7e308a97784cd58d19410944 100644 (file)
@@ -6240,13 +6240,15 @@ parse_real(const char *value, double *result, int flags, const char **hintmsg)
if (hintmsg)
*hintmsg = NULL;
- errno = 0;
val = strtod(value, &endptr);
+ if (endptr == value)
+ return false; /* no HINT for syntax error */
- if (endptr == value || errno == ERANGE)
- return false; /* no HINT for these cases */
-
- /* reject NaN (infinities will fail range checks later) */
+ /*
+ * We ignore strtod's errno, so that out-of-range inputs will just result
+ * in zero or infinity values. Subsequent range checks will reject those
+ * if necessary. We do need to reject NaN explicitly, however.
+ */
if (isnan(val))
return false; /* treat same as syntax error; no HINT */