aboutsummaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1994-03-23 00:34:44 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1994-03-23 00:34:44 +0000
commit51f839331913d9cb9f221ce36e4f18e9e7876e57 (patch)
tree9c3653364a2ecf40f0af0221900de41ca2a143ad /gdb/values.c
parentf7a26f1b782dde8667653109168a304606d82766 (diff)
downloadgdb-51f839331913d9cb9f221ce36e4f18e9e7876e57.zip
gdb-51f839331913d9cb9f221ce36e4f18e9e7876e57.tar.gz
gdb-51f839331913d9cb9f221ce36e4f18e9e7876e57.tar.bz2
* values.c (set_internalvar): Don't set var->value until we are
sure there won't be an error().
Diffstat (limited to 'gdb/values.c')
-rw-r--r--gdb/values.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/gdb/values.c b/gdb/values.c
index 11ed6f1..331a3e0 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -457,19 +457,31 @@ set_internalvar (var, val)
struct internalvar *var;
value_ptr val;
{
+ value_ptr newval;
+
#ifdef IS_TRAPPED_INTERNALVAR
if (IS_TRAPPED_INTERNALVAR (var->name))
SET_TRAPPED_INTERNALVAR (var, val, 0, 0, 0);
#endif
- free ((PTR)var->value);
- var->value = value_copy (val);
+ newval = value_copy (val);
+
/* Force the value to be fetched from the target now, to avoid problems
later when this internalvar is referenced and the target is gone or
has changed. */
- if (VALUE_LAZY (var->value))
- value_fetch_lazy (var->value);
- release_value (var->value);
+ if (VALUE_LAZY (newval))
+ value_fetch_lazy (newval);
+
+ /* Begin code which must not call error(). If var->value points to
+ something free'd, an error() obviously leaves a dangling pointer.
+ But we also get a danling pointer if var->value points to
+ something in the value chain (i.e., before release_value is
+ called), because after the error free_all_values will get called before
+ long. */
+ free ((PTR)var->value);
+ var->value = newval;
+ release_value (newval);
+ /* End code which must not call error(). */
}
char *