]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35720: Fixing a memory leak in pymain_parse_cmdline_impl() (GH-11528)
authorLucas Cimon <lucas.cimon@gmail.com>
Tue, 22 Jan 2019 16:15:01 +0000 (17:15 +0100)
committerVictor Stinner <vstinner@redhat.com>
Tue, 22 Jan 2019 16:15:01 +0000 (17:15 +0100)
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.

Misc/NEWS.d/next/Core and Builtins/2019-01-12-23-33-04.bpo-35720.LELKQx.rst [new file with mode: 0644]
Modules/main.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-01-12-23-33-04.bpo-35720.LELKQx.rst b/Misc/NEWS.d/next/Core and Builtins/2019-01-12-23-33-04.bpo-35720.LELKQx.rst
new file mode 100644 (file)
index 0000000..9c57ebc
--- /dev/null
@@ -0,0 +1 @@
+Fixed a minor memory leak in pymain_parse_cmdline_impl function in Modules/main.c
\ No newline at end of file
index 8e66ddded419a31cacd2c4a8f5e05cc2a011ed89..da79a6397b381a31afcfaea9e644474d0cc187fb 100644 (file)
@@ -1376,6 +1376,7 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config,
             goto done;
         }
         pymain_clear_cmdline(pymain, cmdline);
+        pymain_clear_pymain(pymain);
         memset(cmdline, 0, sizeof(*cmdline));
         config->utf8_mode = new_utf8_mode;
         config->coerce_c_locale = new_coerce_c_locale;