diff options
author | Michael W. Hudson <mwh@python.net> | 2002-03-11 10:12:58 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2002-03-11 10:12:58 (GMT) |
commit | 43efb9a1afe553b6c215fbad6225474ef924c4bc (patch) | |
tree | 781372101f04ffc0b36f34dd5998c645319251ad | |
parent | 244ca00bf084d17d8d1364458cfcd8b4ece4837e (diff) | |
download | cpython-43efb9a1afe553b6c215fbad6225474ef924c4bc.zip cpython-43efb9a1afe553b6c215fbad6225474ef924c4bc.tar.gz cpython-43efb9a1afe553b6c215fbad6225474ef924c4bc.tar.bz2 |
Probably should have merged the two checkins to this file (oh well).
backport jhylton's checkin of
revision 2.98 of abstract.c
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.c | 10 |
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; |