This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Memory leak fixes
>>>>> "Ali" == Ali Lakhia <lakhia@alumni.utexas.net> writes:
Ali> I found the leak using a static checker. It is known to have false
Ali> positives! :-)
Ok, I suspected that might be the case.
Ali> Â Âdo_cleanups (cleanup_chain);
Ali> + Âxfree (filename);
Tom> This one is also covered by a cleanup.
Ali> I don't see any cleanup calls. filename gets allocated by
Ali> build_address_symbolic() and nothing is freeing it as far as I can
Ali> tell.
Near the top of the function:
struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &name);
make_cleanup (free_current_contents, &filename);
This installs a cleanup that frees `name'. It is run by the do_cleanups
call at the end of the function.
I think the GDB internals manual has a section on "cleanups" and how
they interact with GDB's exception mechanism. An analyzer looking for
leaks has to know about this, because it is used pervasively throughout
GDB.
Tom