diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1994-03-23 00:34:44 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1994-03-23 00:34:44 +0000 |
commit | 51f839331913d9cb9f221ce36e4f18e9e7876e57 (patch) | |
tree | 9c3653364a2ecf40f0af0221900de41ca2a143ad /gdb | |
parent | f7a26f1b782dde8667653109168a304606d82766 (diff) | |
download | gdb-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')
-rw-r--r-- | gdb/ChangeLog | 3 | ||||
-rw-r--r-- | gdb/values.c | 22 |
2 files changed, 20 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4f138f5..f190740 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,8 @@ Tue Mar 22 15:28:33 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + * values.c (set_internalvar): Don't set var->value until we are + sure there won't be an error(). + * remote.c (get_offsets): Reinstate comment which was in remote_wait about use of SECT_OFF_TEXT and so on. 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 * |