xfree/make_cleanup memory leak pattern?

Jan Kratochvil jan.kratochvil@redhat.com
Wed Jan 11 00:31:00 GMT 2012


On Wed, 11 Jan 2012 01:25:06 +0100, Khoo Yit Phang wrote:
> I noticed the following code pattern in various places in GDB:
> 	script = compute_python_string (cmd->body_list[0]);
> 	...
> 	xfree (script);
> 
> and also others like:
> 	full_path = tilde_expand (filename);
> 	...
> 	cleanup = make_cleanup (xfree, full_path); 

immediate_quit will cause:
	fatal ("Quit");

which calls throw_exception in the end so all the intermediate cleanup
functions get called.  You can trace/debug it yourself.

I do not see a leak there.  Could you provide some debugging output proving
the memory is being leaked?


Thanks,
Jan



More information about the Gdb mailing list