summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/complexobject.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index ee464ca..63827d2 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.4 alpha 1?
Core and builtins
-----------------
+- complex(obj) could leak a little memory if obj wasn't a string or
+ number.
+
- zip() with no arguments now returns an empty list instead of raising
a TypeError exception.
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 4367ff6..d50a6eb2 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -882,6 +882,9 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
((i != NULL) && (nbi == NULL || nbi->nb_float == NULL))) {
PyErr_SetString(PyExc_TypeError,
"complex() argument must be a string or a number");
+ if (own_r) {
+ Py_DECREF(r);
+ }
return NULL;
}
if (PyComplex_Check(r)) {