summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/C API/2020-05-01-17-28-04.bpo-40412.dE0D8N.rst1
-rw-r--r--Python/import.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/C API/2020-05-01-17-28-04.bpo-40412.dE0D8N.rst b/Misc/NEWS.d/next/C API/2020-05-01-17-28-04.bpo-40412.dE0D8N.rst
new file mode 100644
index 0000000..92bfcdd
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-05-01-17-28-04.bpo-40412.dE0D8N.rst
@@ -0,0 +1 @@
+Nullify inittab_copy during finalization, preventing future interpreter initializations in an embedded situation from crashing. Patch by Gregory Szorc.
diff --git a/Python/import.c b/Python/import.c
index 8c94e0e..400b02a 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -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);
}