From c183444f7e2640b054956474d71aae6e8d31a543 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 18 Mar 2019 22:24:28 +0100 Subject: bpo-36301: Fix Py_Main() memory leaks (GH-12420) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bpo-36301, bpo-36333: * Fix memory allocator used by _PyPathConfig_ClearGlobal(): force the default allocator. * _PyPreConfig_ReadFromArgv(): free init_ctype_locale memory. * pymain_main(): call pymain_free() on init error Co-Authored-By: Stéphane Wirtel --- Python/pathconfig.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Python/pathconfig.c') diff --git a/Python/pathconfig.c b/Python/pathconfig.c index fb2d19e279..0ee87c4252 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -149,7 +149,12 @@ done: void _PyPathConfig_ClearGlobal(void) { + PyMemAllocatorEx old_alloc; + _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); + _PyPathConfig_Clear(&_Py_path_config); + + PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); } -- cgit v1.2.1