summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-06-05 07:48:36 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-06-05 07:48:36 (GMT)
commit484c913ed9fc438cedd2757d6124ab1bac4239be (patch)
tree36dcbd6cf4ee5199e2d7873feefbf0e3e3b3dcc1 /Objects
parent3c5fa560ed6ae990e92afb0d2f77463c0ca73ab0 (diff)
downloadcpython-484c913ed9fc438cedd2757d6124ab1bac4239be.zip
cpython-484c913ed9fc438cedd2757d6124ab1bac4239be.tar.gz
cpython-484c913ed9fc438cedd2757d6124ab1bac4239be.tar.bz2
Issue #27225: Fixed a reference leak in type_new when setting __new__ fails.
Patch by Xiang Zhang.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 19e6596..317334f 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2575,8 +2575,10 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
tmp = PyStaticMethod_New(tmp);
if (tmp == NULL)
goto error;
- if (_PyDict_SetItemId(dict, &PyId___new__, tmp) < 0)
+ if (_PyDict_SetItemId(dict, &PyId___new__, tmp) < 0) {
+ Py_DECREF(tmp);
goto error;
+ }
Py_DECREF(tmp);
}