summaryrefslogtreecommitdiffstats
path: root/Objects/complexobject.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-08-15 01:16:37 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-08-15 01:16:37 (GMT)
commit465fa3dac49e5bbbb7904c755ff999dd5362c83e (patch)
tree947000be70978b28bd786bee9876ca2b3e3fc36f /Objects/complexobject.c
parent90b182c16c2e9ccf238dde897ff9434570f8da7b (diff)
downloadcpython-465fa3dac49e5bbbb7904c755ff999dd5362c83e.zip
cpython-465fa3dac49e5bbbb7904c755ff999dd5362c83e.tar.gz
cpython-465fa3dac49e5bbbb7904c755ff999dd5362c83e.tar.bz2
complex_new(): This could leak when the argument was neither string nor
number. This accounts for the 2 refcount leaks per test_complex run Michael Hudson discovered (I figured only I would have the stomach to look for leaks in floating-point code <wink>).
Diffstat (limited to 'Objects/complexobject.c')
-rw-r--r--Objects/complexobject.c3
1 files changed, 3 insertions, 0 deletions
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)) {