mirror of https://github.com/python/cpython
fix possible refleak (closes #14752)
This commit is contained in:
parent
d9e4a414d7
commit
89a6e9a27b
|
@ -3527,6 +3527,7 @@ add_methods(PyTypeObject *type, PyMethodDef *meth)
|
|||
|
||||
for (; meth->ml_name != NULL; meth++) {
|
||||
PyObject *descr;
|
||||
int err;
|
||||
if (PyDict_GetItemString(dict, meth->ml_name) &&
|
||||
!(meth->ml_flags & METH_COEXIST))
|
||||
continue;
|
||||
|
@ -3550,9 +3551,10 @@ add_methods(PyTypeObject *type, PyMethodDef *meth)
|
|||
}
|
||||
if (descr == NULL)
|
||||
return -1;
|
||||
if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0)
|
||||
return -1;
|
||||
err = PyDict_SetItemString(dict, meth->ml_name, descr);
|
||||
Py_DECREF(descr);
|
||||
if (err < 0)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue