mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #15142: Fix reference leak when deallocating instances of types created using PyType_FromSpec().
This commit is contained in:
commit
a4db02c7a3
2 changed files with 9 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue