FYI: fix PR 11098

Tom Tromey tromey@redhat.com
Wed Mar 3 18:31:00 GMT 2010


I'm checking this in on the trunk and the 7.1 branch.

This fixes PR 11098.  The bug is that in some situations, the new
"print_value" in varobj.c:install_new_value can be NULL, leading to a
crash when it is unconditionally passed to strcmp.

I don't have a simple test case.  However, the problem is reasonably
obvious from reading the code; var->value is checked against NULL
earlier in the function, and this is what causes value_get_print_value
to return NULL.

Built and regtested on x86-64 (compile farm).  I also verified it with
the full test case here.

Tom

2010-03-03  Tom Tromey  <tromey@redhat.com>

	PR mi/11098:
	* varobj.c (install_new_value): Handle case where new print_value
	is NULL.

diff --git a/gdb/varobj.c b/gdb/varobj.c
index b4b2461..c4d02c9 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -1593,7 +1593,10 @@ install_new_value (struct varobj *var, struct value *value, int initial)
     {
       xfree (print_value);
       print_value = value_get_print_value (var->value, var->format, var);
-      if (!var->print_value || strcmp (var->print_value, print_value) != 0)
+      if ((var->print_value == NULL && print_value != NULL)
+	  || (var->print_value != NULL && print_value == NULL)
+	  || (var->print_value != NULL && print_value != NULL
+	      && strcmp (var->print_value, print_value) != 0))
 	changed = 1;
     }
   if (var->print_value)



More information about the Gdb-patches mailing list