summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-03-08 21:28:54 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2002-03-08 21:28:54 (GMT)
commit0522d9891aec9b7d49049a8a47b687c81929e02d (patch)
tree5d50a44b2884fa096399230347975bbaadd26e4c
parent6ae6a43a77e3170cc952d182b67533b560eb6dbe (diff)
downloadcpython-0522d9891aec9b7d49049a8a47b687c81929e02d.zip
cpython-0522d9891aec9b7d49049a8a47b687c81929e02d.tar.gz
cpython-0522d9891aec9b7d49049a8a47b687c81929e02d.tar.bz2
Fix leak of NotImplemented in previous checkin to PyNumber_Add().
If result == Py_NotImplemented, always DECREF it before assigning a new value to result.
-rw-r--r--Objects/abstract.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 2207602..162c53c 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -605,16 +605,18 @@ PyNumber_Add(PyObject *v, PyObject *w)
PyObject *result = binary_op1(v, w, NB_SLOT(nb_add));
if (result == Py_NotImplemented) {
PySequenceMethods *m = v->ob_type->tp_as_sequence;
- Py_DECREF(result);
- if (m && m->sq_concat)
+ if (m && m->sq_concat) {
+ Py_DECREF(result);
result = (*m->sq_concat)(v, w);
+ }
if (result == Py_NotImplemented) {
- PyErr_Format(
+ Py_DECREF(result);
+ PyErr_Format(
PyExc_TypeError,
"unsupported operand types for +: '%s' and '%s'",
v->ob_type->tp_name,
w->ob_type->tp_name);
- result = NULL;
+ result = NULL;
}
}
return result;