summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-05-01 23:06:23 (GMT)
committerGitHub <noreply@github.com>2020-05-01 23:06:23 (GMT)
commit1205afb3e10194fe22fa76385abb7e522144eb29 (patch)
tree1f08b7636d20424caf0c02ad0b5a97da00af8625 /Python
parente05828055e5165cc7268ea3bea33adc502e054a1 (diff)
downloadcpython-1205afb3e10194fe22fa76385abb7e522144eb29.zip
cpython-1205afb3e10194fe22fa76385abb7e522144eb29.tar.gz
cpython-1205afb3e10194fe22fa76385abb7e522144eb29.tar.bz2
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 (cherry picked from commit 64224a4727321a8dd33e6f769edda401193ebef0) Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Python/import.c b/Python/import.c
index 495012d..b4074d1 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -300,6 +300,7 @@ _PyImport_Fini2(void)
/* Free memory allocated by PyImport_ExtendInittab() */
PyMem_RawFree(inittab_copy);
+ inittab_copy = NULL;
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
}