Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 3962:f08d7f368ebf legacy-trunk
Include mymath.h instead of declaring prototypes for math functions.
Fix leak and unchecked error in complex().
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 08 Aug 1996 18:49:41 +0000 |
| parents | d55cdf43c240 |
| children | 18c32714f8ba |
line wrap: on
line diff
--- a/Python/bltinmodule.c Thu Aug 08 18:44:36 1996 +0000 +++ b/Python/bltinmodule.c Thu Aug 08 18:49:41 1996 +0000 @@ -33,6 +33,8 @@ #include "compile.h" #include "eval.h" +#include "mymath.h" + /* Forward */ static object *filterstring PROTO((object *, object *)); static object *filtertuple PROTO((object *, object *)); @@ -284,7 +286,7 @@ object *self; object *args; { - object *r, *i; + object *r, *i, *tmp; number_methods *nbr, *nbi; Py_complex cr, ci; @@ -302,7 +304,11 @@ if (is_complexobject(r)) cr = ((complexobject*)r)->cval; else { - cr.real = getfloatvalue((*nbr->nb_float)(r)); + tmp = (*nbr->nb_float)(r); + if (tmp == NULL) + return NULL; + cr.real = getfloatvalue(tmp); + DECREF(tmp); cr.imag = 0.; } if (i == NULL) { @@ -312,7 +318,11 @@ else if (is_complexobject(i)) ci = ((complexobject*)i)->cval; else { - ci.real = getfloatvalue((*nbi->nb_float)(i)); + tmp = (*nbr->nb_float)(r); + if (tmp == NULL) + return NULL; + ci.real = getfloatvalue(tmp); + DECREF(tmp); ci.imag = 0.; } cr.real -= ci.imag; @@ -1354,8 +1364,6 @@ object *self; object *args; { - extern double floor PROTO((double)); - extern double ceil PROTO((double)); double x; double f; int ndigits = 0;
