This is the mail archive of the gdb@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]

xfree/make_cleanup memory leak pattern?


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


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