]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #27225: Fixed a reference leak in type_new when setting __new__ fails.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 5 Jun 2016 07:48:36 +0000 (10:48 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 5 Jun 2016 07:48:36 +0000 (10:48 +0300)
Patch by Xiang Zhang.

Objects/typeobject.c

index 19e65963d58f5fade5b578f1d520b88642987092..317334f739a5a21dc777a8fc41d7e97ef4be3a1f 100644 (file)
@@ -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);
     }