mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
fix possible refleak (closes #14752)
This commit is contained in:
parent
f1aeef27b3
commit
f1ae5cf5c7
1 changed files with 4 additions and 2 deletions
|
@ -3565,6 +3565,7 @@ add_methods(PyTypeObject *type, PyMethodDef *meth)
|
||||||
|
|
||||||
for (; meth->ml_name != NULL; meth++) {
|
for (; meth->ml_name != NULL; meth++) {
|
||||||
PyObject *descr;
|
PyObject *descr;
|
||||||
|
int err;
|
||||||
if (PyDict_GetItemString(dict, meth->ml_name) &&
|
if (PyDict_GetItemString(dict, meth->ml_name) &&
|
||||||
!(meth->ml_flags & METH_COEXIST))
|
!(meth->ml_flags & METH_COEXIST))
|
||||||
continue;
|
continue;
|
||||||
|
@ -3588,9 +3589,10 @@ add_methods(PyTypeObject *type, PyMethodDef *meth)
|
||||||
}
|
}
|
||||||
if (descr == NULL)
|
if (descr == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0)
|
err = PyDict_SetItemString(dict, meth->ml_name, descr);
|
||||||
return -1;
|
|
||||||
Py_DECREF(descr);
|
Py_DECREF(descr);
|
||||||
|
if (err < 0)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue