summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-06-05 07:50:16 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-06-05 07:50:16 (GMT)
commit841de28035a5808046ab23077163c58b7eb557fe (patch)
treed4a5c63975c9715cb3733e5130af009bc65afc9d
parentb07b57c52269e3a966e888a8ef43561be60bdbb7 (diff)
parent484c913ed9fc438cedd2757d6124ab1bac4239be (diff)
downloadcpython-841de28035a5808046ab23077163c58b7eb557fe.zip
cpython-841de28035a5808046ab23077163c58b7eb557fe.tar.gz
cpython-841de28035a5808046ab23077163c58b7eb557fe.tar.bz2
Issue #27225: Fixed a reference leak in type_new when setting __new__ fails.
Patch by Xiang Zhang.
-rw-r--r--Objects/typeobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 78d5c1e..d42054a 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2580,8 +2580,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);
}