diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-03-18 21:24:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-18 21:24:28 (GMT) |
commit | c183444f7e2640b054956474d71aae6e8d31a543 (patch) | |
tree | af6f895fc245d43f78618918fef63e37ce7b5196 /Python/pathconfig.c | |
parent | a10d426bab66a4e1f20d5e1b9aee3dbb435cf309 (diff) | |
download | cpython-c183444f7e2640b054956474d71aae6e8d31a543.zip cpython-c183444f7e2640b054956474d71aae6e8d31a543.tar.gz cpython-c183444f7e2640b054956474d71aae6e8d31a543.tar.bz2 |
bpo-36301: Fix Py_Main() memory leaks (GH-12420)
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 <stephane@wirtel.be>
Diffstat (limited to 'Python/pathconfig.c')
-rw-r--r-- | Python/pathconfig.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/pathconfig.c b/Python/pathconfig.c index fb2d19e..0ee87c4 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); } |