Mercurial > cpython-lru_cache-weakref
changeset 22194:fc6dc2ea25cf legacy-trunk
Fix leak of NotImplemented in previous checkin to PyNumber_Add().
If result == Py_NotImplemented, always DECREF it before assigning a
new value to result.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Fri, 08 Mar 2002 21:28:54 +0000 |
| parents | 98a3fa5f687c |
| children | 24ba693e9c73 |
| files | Objects/abstract.c |
| diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Objects/abstract.c Fri Mar 08 21:11:37 2002 +0000 +++ b/Objects/abstract.c Fri Mar 08 21:28:54 2002 +0000 @@ -605,16 +605,18 @@ 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;
