diff options
author | Guido van Rossum <guido@python.org> | 1991-12-16 15:43:14 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-12-16 15:43:14 (GMT) |
commit | 7fa52f84c7c5479b75c5a1e168a2edaf7072f9de (patch) | |
tree | 93caca101559c1c40336731e5c92a310538c2755 | |
parent | fb905c3ebfe71c619cf4a4cb8bf162beb3526db2 (diff) | |
download | cpython-7fa52f84c7c5479b75c5a1e168a2edaf7072f9de.zip cpython-7fa52f84c7c5479b75c5a1e168a2edaf7072f9de.tar.gz cpython-7fa52f84c7c5479b75c5a1e168a2edaf7072f9de.tar.bz2 |
Explicitly check for weird values after calling pow().
-rw-r--r-- | Objects/floatobject.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 77015b9..43cefda 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -37,6 +37,14 @@ extern int errno; #include <ctype.h> #include <math.h> +#ifdef HUGE_VAL +#define CHECK(x) if (errno != 0) ; \ + else if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \ + else errno = ERANGE +#else +#define CHECK(x) /* Don't know how to check */ +#endif + #ifndef THINK_C extern double fmod PROTO((double, double)); extern double pow PROTO((double, double)); @@ -262,6 +270,7 @@ float_pow(v, w) } errno = 0; ix = pow(iv, iw); + CHECK(ix); if (errno != 0) { /* XXX could it be another type of error? */ err_errno(OverflowError); |