diff options
author | Guido van Rossum <guido@python.org> | 2000-05-08 14:29:38 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-05-08 14:29:38 +0000 |
commit | caf579125e60b9fa2147329272451247b4e27fd5 (patch) | |
tree | d7f6d7c8b6ce854afcc3f455cd1253eb08090337 /Modules/mathmodule.c | |
parent | bca52aa4d2c5151b9119f585b760f25c72e08202 (diff) | |
download | cpython-caf579125e60b9fa2147329272451247b4e27fd5.tar.gz |
Trent Mick:
Fix overflow bug in ldexp(x, exp). The 'exp' argument maps to a C int for the
math library call [double ldexp(double, int)], however the 'd'
PyArg_ParseTuple formatter was used to yield a double, which was subsequently
cast to an int. This could overflow.
[GvR: mysteriously, on Solaris 2.7, ldexp(1, 2147483647) returns Inf
while ldexp(1, 2147483646) raises OverflowError; this seems a bug in
the math library (it also takes a real long time to compute the
Inf outcome). Does this point to a bug in the CHECK() macro? It
should have discovered that the result was outside the HUGE_VAL range.]
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r-- | Modules/mathmodule.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index a241c60aec..d01de90569 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -196,13 +196,13 @@ math_ldexp(self, args) PyObject *self; PyObject *args; { - double x, y; - /* Cheat -- allow float as second argument */ - if (! PyArg_Parse(args, "(dd)", &x, &y)) + double x; + int exp; + if (! PyArg_Parse(args, "(di)", &x, &exp)) return NULL; errno = 0; PyFPE_START_PROTECT("ldexp", return 0) - x = ldexp(x, (int)y); + x = ldexp(x, exp); PyFPE_END_PROTECT(x) CHECK(x); if (errno != 0) |