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>
diff --git a/Python/preconfig.c b/Python/preconfig.c
index a86ece5..1efc7ee 100644
--- a/Python/preconfig.c
+++ b/Python/preconfig.c
@@ -758,6 +758,7 @@
done:
if (init_ctype_locale != NULL) {
setlocale(LC_CTYPE, init_ctype_locale);
+ PyMem_RawFree(init_ctype_locale);
}
_PyPreConfig_Clear(&save_config);
Py_UTF8Mode = init_utf8_mode ;