PR python/12533:

* value.h (release_value_or_incref): Declare.
	* value.c (struct value) <released>: New field.
	(free_all_values, release_value, value_release_to_mark): Update
	'released'.
	(release_value_or_incref): New function.
	* python/py-value.c (valpy_new): Use release_value_or_incref.
	(value_to_value_object): Likewise.
	* varobj.c (install_new_value): Move value_incref earlier.
This commit is contained in:
Tom Tromey
2011-12-22 19:51:10 +00:00
parent 87784a4754
commit e848a8a515
5 changed files with 50 additions and 10 deletions

View 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