summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-18 21:24:28 (GMT)
committerGitHub <noreply@github.com>2019-03-18 21:24:28 (GMT)
commitc183444f7e2640b054956474d71aae6e8d31a543 (patch)
treeaf6f895fc245d43f78618918fef63e37ce7b5196 /Modules/main.c
parenta10d426bab66a4e1f20d5e1b9aee3dbb435cf309 (diff)
downloadcpython-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 'Modules/main.c')
-rw-r--r--Modules/main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 5c7f7e4..50fecc9 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -888,13 +888,13 @@ pymain_main(_PyArgv *args)
PyInterpreterState *interp;
err = pymain_init(args, &interp);
if (_Py_INIT_FAILED(err)) {
- _Py_ExitInitError(err);
+ goto exit_init_error;
}
int exitcode = 0;
err = pymain_run_python(interp, &exitcode);
if (_Py_INIT_FAILED(err)) {
- _Py_ExitInitError(err);
+ goto exit_init_error;
}
if (Py_FinalizeEx() < 0) {
@@ -910,6 +910,10 @@ pymain_main(_PyArgv *args)
}
return exitcode;
+
+exit_init_error:
+ pymain_free();
+ _Py_ExitInitError(err);
}