This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] python: Fix memleak in do_start_initialization
- From: Tom Tromey <tom at tromey dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: gdb-patches at sourceware dot org
- Date: Sun, 26 Nov 2017 12:00:32 -0700
- Subject: Re: [PATCH] python: Fix memleak in do_start_initialization
- Authentication-results: sourceware.org; auth=none
- References: <20171126035308.12274-1-simon.marchi@polymtl.ca>
>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:
Simon> While playing with valgrind, I noticed that the progname variable in
Simon> do_start_initialization is not being freed (concat returns a malloc'ed
Simon> string). Use a unique_xmalloc_ptr to manage it.
I don't think this is quite correct.
On the Python 2 branch, the code does this:
Py_SetProgramName (progname);
The docs for Py_SetProgramName say:
The argument should point to a
zero-terminated character string in static storage whose contents
will not change for the duration of the program's execution.
I think a comment referring to the Python docs would be better.
And, freeing progname on the Python 3 branch is ok.
Maybe the Python 2 branch could pass "progname.release ()".
Tom