mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
Replace SIGFPE paranoia around strtod and atof. I don't believe these
fncs are allowed to raise SIGFPE (see the C std), but OK by me if people using --with-fpectl want to pay for checking anyway.
This commit is contained in:
parent
7f577e7fd4
commit
858346e484
1 changed files with 4 additions and 0 deletions
|
@ -182,7 +182,9 @@ PyFloat_FromString(PyObject *v, char **pend)
|
||||||
* whether strtod sets errno on underflow is not defined, so we can't
|
* whether strtod sets errno on underflow is not defined, so we can't
|
||||||
* key off errno.
|
* key off errno.
|
||||||
*/
|
*/
|
||||||
|
PyFPE_START_PROTECT("strtod", return NULL)
|
||||||
x = strtod(s, (char **)&end);
|
x = strtod(s, (char **)&end);
|
||||||
|
PyFPE_END_PROTECT(x)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
/* Believe it or not, Solaris 2.6 can move end *beyond* the null
|
/* Believe it or not, Solaris 2.6 can move end *beyond* the null
|
||||||
byte at the end of the string, when the input is inf(inity). */
|
byte at the end of the string, when the input is inf(inity). */
|
||||||
|
@ -210,7 +212,9 @@ PyFloat_FromString(PyObject *v, char **pend)
|
||||||
if (x == 0.0) {
|
if (x == 0.0) {
|
||||||
/* See above -- may have been strtod being anal
|
/* See above -- may have been strtod being anal
|
||||||
about denorms. */
|
about denorms. */
|
||||||
|
PyFPE_START_PROTECT("atof", return NULL)
|
||||||
x = atof(s);
|
x = atof(s);
|
||||||
|
PyFPE_END_PROTECT(x)
|
||||||
errno = 0; /* whether atof ever set errno is undefined */
|
errno = 0; /* whether atof ever set errno is undefined */
|
||||||
}
|
}
|
||||||
return PyFloat_FromDouble(x);
|
return PyFloat_FromDouble(x);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue