mirror of
https://github.com/python/cpython.git
synced 2025-11-03 11:23:31 +00:00
Fix leak of NotImplemented in previous checkin to PyNumber_Add().
If result == Py_NotImplemented, always DECREF it before assigning a new value to result.
This commit is contained in:
parent
6ae6a43a77
commit
0522d9891a
1 changed files with 6 additions and 4 deletions
|
|
@ -605,10 +605,12 @@ PyNumber_Add(PyObject *v, PyObject *w)
|
||||||
PyObject *result = binary_op1(v, w, NB_SLOT(nb_add));
|
PyObject *result = binary_op1(v, w, NB_SLOT(nb_add));
|
||||||
if (result == Py_NotImplemented) {
|
if (result == Py_NotImplemented) {
|
||||||
PySequenceMethods *m = v->ob_type->tp_as_sequence;
|
PySequenceMethods *m = v->ob_type->tp_as_sequence;
|
||||||
|
if (m && m->sq_concat) {
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
if (m && m->sq_concat)
|
|
||||||
result = (*m->sq_concat)(v, w);
|
result = (*m->sq_concat)(v, w);
|
||||||
|
}
|
||||||
if (result == Py_NotImplemented) {
|
if (result == Py_NotImplemented) {
|
||||||
|
Py_DECREF(result);
|
||||||
PyErr_Format(
|
PyErr_Format(
|
||||||
PyExc_TypeError,
|
PyExc_TypeError,
|
||||||
"unsupported operand types for +: '%s' and '%s'",
|
"unsupported operand types for +: '%s' and '%s'",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue