diff options
-rwxr-xr-x | ChangeLog | 6 | ||||
-rw-r--r-- | debug.c | 4 | ||||
-rw-r--r-- | interpret.h | 3 |
3 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,9 @@ +2019-01-20 Arnold D. Robbins <arnold@skeeve.com> + + * debug.c (do_set_var): Add comments before calls to assoc_set. + * interpret.h (r_interpret): For Op_sub_array, deref the subscript + appropriately. Thanks to Andy Schorr for the catch. + 2019-01-15 Arnold D. Robbins <arnold@skeeve.com> * array.c (asort_actual): Use assoc_set in 2 places. @@ -1270,6 +1270,8 @@ do_set_var(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) arg = arg->next; val = arg->a_node; newval = dupnode(val); + // subs should not be freed, so + // use dupnode in call to assoc_set. assoc_set(r, dupnode(subs), newval); fprintf(out_fp, "%s[\"%.*s\"] = ", name, (int) subs->stlen, subs->stptr); valinfo(newval, fprintf, out_fp); @@ -1280,6 +1282,8 @@ do_set_var(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) array = make_array(); array->vname = estrdup(subs->stptr, subs->stlen); array->parent_array = r; + // subs should not be freed, so + // use dupnode in call to assoc_set. assoc_set(r, dupnode(subs), array); r = array; } else if (value->type != Node_var_array) { diff --git a/interpret.h b/interpret.h index 53abadcb..e9896672 100644 --- a/interpret.h +++ b/interpret.h @@ -310,7 +310,8 @@ uninitialized_scalar: t2 = force_string(t2); fatal(_("attempt to use scalar `%s[\"%.*s\"]' as an array"), array_vname(t1), (int) t2->stlen, t2->stptr); - } + } else + DEREF(t2); PUSH(r); break; |