xfree/make_cleanup memory leak pattern?

Khoo Yit Phang khooyp@cs.umd.edu
Wed Jan 11 00:25:00 GMT 2012


Hi,

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); 

If I understand correctly, wouldn't these patterns lead to a memory leak if the user manages to trigger a SIGINT (with immediate_quit in effect) at the "..." in between the memory allocation and xfree/make_cleanup? It's a tiny window in most cases, but something like compute_python_string could take some time.

Yit
January 10, 2012



More information about the Gdb mailing list