This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix small memory leak in mi-cmd-var.c
- From: Nick Roberts <nickrob at snap dot net dot nz>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 8 Dec 2006 15:05:50 +1300
- Subject: [PATCH] Fix small memory leak in mi-cmd-var.c
This patch fixes a small memory leak (sizeof (struct varobj *) = 4)
that occurs each time -var-update is issued when rootcount = 0.
--
Nick http://www.inet.net.nz/~nickrob
2006-12-08 Nick Roberts <nickrob@snap.net.nz>
* mi/mi-cmd-var.c (mi_cmd_var_update): Fix memory leak.
*** mi-cmd-var.c 30 Nov 2006 11:45:31 +1300 1.26
--- mi-cmd-var.c 08 Dec 2006 15:04:16 +1300
*************** mi_cmd_var_update (char *command, char *
*** 500,509 ****
if ((*name == '*') && (*(name + 1) == '\0'))
{
nv = varobj_list (&rootlist);
if (mi_version (uiout) <= 1)
! cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
else
! cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
if (nv <= 0)
{
do_cleanups (cleanup);
--- 500,510 ----
if ((*name == '*') && (*(name + 1) == '\0'))
{
nv = varobj_list (&rootlist);
+ cleanup = make_cleanup (xfree, rootlist);
if (mi_version (uiout) <= 1)
! make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
else
! make_cleanup_ui_out_list_begin_end (uiout, "changelist");
if (nv <= 0)
{
do_cleanups (cleanup);
*************** mi_cmd_var_update (char *command, char *
*** 515,521 ****
varobj_update_one (*cr, print_values);
cr++;
}
- xfree (rootlist);
do_cleanups (cleanup);
}
else
--- 516,521 ----