]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Explicitly check for weird values after calling pow().
authorGuido van Rossum <guido@python.org>
Mon, 16 Dec 1991 15:43:14 +0000 (15:43 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 16 Dec 1991 15:43:14 +0000 (15:43 +0000)
Objects/floatobject.c

index 77015b9032e483ee0b0592c3284c869ef5ed97d3..43cefda562cd4f0cbd25acb6058dd99f4d0db5bb 100644 (file)
@@ -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);