From 89a6e9a27b565d8143c3e064aae92e831ff14801 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 8 May 2012 09:22:24 -0400 Subject: [PATCH] fix possible refleak (closes #14752) --- Objects/typeobject.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 13a20f7905f..9430d3959c6 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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; }