mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-40412: Nullify inittab_copy during finalization (GH-19746)
Otherwise we leave a dangling pointer to free'd memory. If we then initialize a new interpreter in the same process and call PyImport_ExtendInittab, we will (likely) crash when calling PyMem_RawRealloc(inittab_copy, ...) since the pointer address is bogus. Automerge-Triggered-By: @brettcannon
This commit is contained in:
parent
831d58d786
commit
64224a4727
2 changed files with 2 additions and 0 deletions
|
@ -298,6 +298,7 @@ _PyImport_Fini2(void)
|
|||
|
||||
/* Free memory allocated by PyImport_ExtendInittab() */
|
||||
PyMem_RawFree(inittab_copy);
|
||||
inittab_copy = NULL;
|
||||
|
||||
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue