diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-03-18-10-56-53.bpo-36333.4dqemZ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-03-18-10-56-53.bpo-36333.4dqemZ.rst new file mode 100644 index 00000000000..e5af44fda40 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-03-18-10-56-53.bpo-36333.4dqemZ.rst @@ -0,0 +1 @@ +Fix leak in _PyRuntimeState_Fini. Contributed by Stéphane Wirtel. diff --git a/Python/pystate.c b/Python/pystate.c index 6a2dc102ecf..36566b76715 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -92,6 +92,11 @@ _PyRuntimeState_Fini(_PyRuntimeState *runtime) runtime->interpreters.mutex = NULL; } + if (runtime->xidregistry.mutex != NULL) { + PyThread_free_lock(runtime->xidregistry.mutex); + runtime->xidregistry.mutex = NULL; + } + PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); }