From: Antoine Pitrou Date: Sat, 23 Jun 2012 12:42:38 +0000 (+0200) Subject: Issue #15142: Fix reference leak when deallocating instances of types created using... X-Git-Tag: v3.3.0b1~125^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=99cc629969cd008272c471a0f7bdd2de04cf67fa;p=thirdparty%2FPython%2Fcpython.git Issue #15142: Fix reference leak when deallocating instances of types created using PyType_FromSpec(). --- diff --git a/Misc/NEWS b/Misc/NEWS index 789f7f78bb46..6f5911003963 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.2.4 Core and Builtins ----------------- +- Issue #15142: Fix reference leak when deallocating instances of types + created using PyType_FromSpec(). + - Issue #10053: Don't close FDs when FileIO.__init__ fails. Loosely based on the work by Hirokazu Yamamoto. diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 934d06f7720f..54a990e01127 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2387,6 +2387,12 @@ PyType_FromSpec(PyType_Spec *spec) res->ht_type.tp_doc = tp_doc; } } + if (res->ht_type.tp_dealloc == NULL) { + /* It's a heap type, so needs the heap types' dealloc. + subtype_dealloc will call the base type's tp_dealloc, if + necessary. */ + res->ht_type.tp_dealloc = subtype_dealloc; + } if (PyType_Ready(&res->ht_type) < 0) goto fail;