]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/varobj.c
PR python/12533:
[thirdparty/binutils-gdb.git] / gdb / varobj.c
index 7c68a93bb034d5b6980a4b432e149a46d1479674..0d5987cb0b76678f9b71a7873946a51520180e08 100644 (file)
@@ -1604,6 +1604,10 @@ install_new_value (struct varobj *var, struct value *value, int initial)
        }
     }
 
+  /* Get a reference now, before possibly passing it to any Python
+     code that might release it.  */
+  if (value != NULL)
+    value_incref (value);
 
   /* Below, we'll be comparing string rendering of old and new
      values.  Don't get string rendering if the value is
@@ -1671,8 +1675,6 @@ install_new_value (struct varobj *var, struct value *value, int initial)
   if (var->value != NULL && var->value != value)
     value_free (var->value);
   var->value = value;
-  if (value != NULL)
-    value_incref (value);
   if (value && value_lazy (value) && intentionally_not_fetched)
     var->not_fetched = 1;
   else