diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-23 12:45:21 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-23 12:45:21 (GMT) |
commit | a4db02c7a38c5669b5678f1e972d8b9c6d3a2238 (patch) | |
tree | cb73e592c63fd9fe7eb6d5a7ba851763a936cfec /Objects | |
parent | edc601855d3ed2494164d48dd12d2d222d23113f (diff) | |
parent | 99cc629969cd008272c471a0f7bdd2de04cf67fa (diff) | |
download | cpython-a4db02c7a38c5669b5678f1e972d8b9c6d3a2238.zip cpython-a4db02c7a38c5669b5678f1e972d8b9c6d3a2238.tar.gz cpython-a4db02c7a38c5669b5678f1e972d8b9c6d3a2238.tar.bz2 |
Issue #15142: Fix reference leak when deallocating instances of types created using PyType_FromSpec().
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 872ed99..d8bdeaf 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2417,6 +2417,12 @@ PyType_FromSpec(PyType_Spec *spec) if (res->ht_type.tp_dictoffset) { res->ht_cached_keys = _PyDict_NewKeysForClass(); } + 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; |