summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-08-08 18:49:41 (GMT)
committerGuido van Rossum <guido@python.org>1996-08-08 18:49:41 (GMT)
commitfe4b6ee77596320353bca3d9f1143d6ed97476f3 (patch)
tree9a097e2ddaf0dfec5ecff56315c69709d77db6e8 /Python
parent1d60614d429eba40cdb3ea5ac0f73f55e15f65fb (diff)
downloadcpython-fe4b6ee77596320353bca3d9f1143d6ed97476f3.zip
cpython-fe4b6ee77596320353bca3d9f1143d6ed97476f3.tar.gz
cpython-fe4b6ee77596320353bca3d9f1143d6ed97476f3.tar.bz2
Include mymath.h instead of declaring prototypes for math functions.
Fix leak and unchecked error in complex().
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 04b2b7d..ea3d30d 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -33,6 +33,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#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 @@ builtin_complex(self, args)
object *self;
object *args;
{
- object *r, *i;
+ object *r, *i, *tmp;
number_methods *nbr, *nbi;
Py_complex cr, ci;
@@ -302,7 +304,11 @@ builtin_complex(self, args)
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 @@ builtin_complex(self, args)
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 @@ builtin_round(self, args)
object *self;
object *args;
{
- extern double floor PROTO((double));
- extern double ceil PROTO((double));
double x;
double f;
int ndigits = 0;