Mailing List Archive

cpython (3.2): fix possible refleak (closes #14752)
http://hg.python.org/cpython/rev/d937b527b76e
changeset: 76836:d937b527b76e
branch: 3.2
parent: 76834:91612618985b
user: Benjamin Peterson <benjamin@python.org>
date: Tue May 08 09:22:24 2012 -0400
summary:
fix possible refleak (closes #14752)

files:
Objects/typeobject.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3527,6 +3527,7 @@

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 @@
}
if (descr == NULL)
return -1;
- if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0)
+ err = PyDict_SetItemString(dict, meth->ml_name, descr);
+ Py_DECREF(descr);
+ if (err < 0)
return -1;
- Py_DECREF(descr);
}
return 0;
}

--
Repository URL: http://hg.python.org/cpython