[Python-checkins] cpython (3.5): Issue #27225: Fixed a reference leak in type_new when setting __new__ fails.

serhiy.storchaka python-checkins at python.org
Sun Jun 5 04:07:10 EDT 2016


https://hg.python.org/cpython/rev/33b53734805b
changeset:   101752:33b53734805b
branch:      3.5
parent:      101749:5c1befa401ca
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sun Jun 05 10:48:36 2016 +0300
summary:
  Issue #27225: Fixed a reference leak in type_new when setting __new__ fails.
Patch by Xiang Zhang.

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


diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2575,8 +2575,10 @@
         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);
     }
 

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


More information about the Python-checkins mailing list