This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] python: Fix memleak in do_start_initialization


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]