* values.c (set_internalvar): Don't set var->value until we are

sure there won't be an error().
This commit is contained in:
Jim Kingdon 1994-03-23 00:34:44 +00:00
parent f7a26f1b78
commit 51f8393319
2 changed files with 20 additions and 5 deletions

View File

@ -1,5 +1,8 @@
Tue Mar 22 15:28:33 1994 Jim Kingdon (kingdon@lioth.cygnus.com) 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.c (get_offsets): Reinstate comment which was in
remote_wait about use of SECT_OFF_TEXT and so on. remote_wait about use of SECT_OFF_TEXT and so on.

View File

@ -457,19 +457,31 @@ set_internalvar (var, val)
struct internalvar *var; struct internalvar *var;
value_ptr val; value_ptr val;
{ {
value_ptr newval;
#ifdef IS_TRAPPED_INTERNALVAR #ifdef IS_TRAPPED_INTERNALVAR
if (IS_TRAPPED_INTERNALVAR (var->name)) if (IS_TRAPPED_INTERNALVAR (var->name))
SET_TRAPPED_INTERNALVAR (var, val, 0, 0, 0); SET_TRAPPED_INTERNALVAR (var, val, 0, 0, 0);
#endif #endif
free ((PTR)var->value); newval = value_copy (val);
var->value = value_copy (val);
/* Force the value to be fetched from the target now, to avoid problems /* 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 later when this internalvar is referenced and the target is gone or
has changed. */ has changed. */
if (VALUE_LAZY (var->value)) if (VALUE_LAZY (newval))
value_fetch_lazy (var->value); value_fetch_lazy (newval);
release_value (var->value);
/* 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 * char *