Commit 89a6e9a2 authored by Benjamin Peterson's avatar Benjamin Peterson

fix possible refleak (closes #14752)

parent d9e4a414
...@@ -3527,6 +3527,7 @@ add_methods(PyTypeObject *type, PyMethodDef *meth) ...@@ -3527,6 +3527,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;
...@@ -3550,9 +3551,10 @@ add_methods(PyTypeObject *type, PyMethodDef *meth) ...@@ -3550,9 +3551,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;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment