This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
xfree/make_cleanup memory leak pattern?
- From: Khoo Yit Phang <khooyp at cs dot umd dot edu>
- To: gdb at sourceware dot org
- Cc: Khoo Yit Phang <khooyp at cs dot umd dot edu>
- Date: Tue, 10 Jan 2012 19:25:06 -0500
- Subject: 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