RFC: fix a cleanup bug in varobj.c

Tom Tromey tromey@redhat.com
Thu Jun 18 15:21:00 GMT 2009


While reading varobj.c I ran across what I believe to be a cleanup
bug.

The bug is that in the early return case, a cleanup is left around,
and gdb might be left switched to the wrong thread.

Built and regtested on x86-64 (compile farm).

I thought I'd see if anybody disagrees before committing this one.
I'll commit it next week if I don't hear anything.

Tom

2009-06-17  Tom Tromey  <tromey@redhat.com>

	* varobj.c (c_value_of_root): Run cleanups before all returns.

Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.135
diff -u -r1.135 varobj.c
--- varobj.c	17 Jun 2009 18:49:36 -0000	1.135
+++ varobj.c	17 Jun 2009 20:37:07 -0000
@@ -2708,12 +2708,11 @@
       /* We need to catch errors here, because if evaluate
          expression fails we want to just return NULL.  */
       gdb_evaluate_expression (var->root->exp, &new_val);
-      return new_val;
     }
 
   do_cleanups (back_to);
 
-  return NULL;
+  return new_val;
 }
 
 static struct value *



More information about the Gdb-patches mailing list