From 7fa52f84c7c5479b75c5a1e168a2edaf7072f9de Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 16 Dec 1991 15:43:14 +0000 Subject: [PATCH] Explicitly check for weird values after calling pow(). --- Objects/floatobject.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 77015b9032e..43cefda562c 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -37,6 +37,14 @@ extern int errno; #include #include +#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);