]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35720: Fixing a memory leak in pymain_parse_cmdline_impl() (GH-11528)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 22 Jan 2019 16:42:13 +0000 (08:42 -0800)
committerGitHub <noreply@github.com>
Tue, 22 Jan 2019 16:42:13 +0000 (08:42 -0800)
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>
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 af2c191b9b9b321abe79189200fb87909a297e70..a745381109d37775913779c975d81107c135d03f 100644 (file)
@@ -2165,6 +2165,7 @@ pymain_read_conf(_PyMain *pymain, _PyCoreConfig *config, _PyCmdline *cmdline)
             goto done;
         }
         pymain_clear_cmdline(pymain, cmdline);
+        pymain_clear_pymain(pymain);
         memset(cmdline, 0, sizeof(*cmdline));
 
         cmdline_get_global_config(cmdline);