bpo-35720: Fixing a memory leak in pymain_parse_cmdline_impl() (GH-11528)
When the loop in the pymain_read_conf function in this same file
calls pymain_init_cmdline_argv() a 2nd time, the pymain->command
buffer of wchar_t is overriden and the previously allocated memory
is never freed.
(cherry picked from commit 35ca1820e19f81f69073f294503cdcd708fe490f)
Co-authored-by: Lucas Cimon <lucas.cimon@gmail.com>
diff --git a/Modules/main.c b/Modules/main.c
index af2c191..a745381 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -2165,6 +2165,7 @@
goto done;
}
pymain_clear_cmdline(pymain, cmdline);
+ pymain_clear_pymain(pymain);
memset(cmdline, 0, sizeof(*cmdline));
cmdline_get_global_config(cmdline);