aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/debug.c b/debug.c
index 9a022669..3e76ae61 100644
--- a/debug.c
+++ b/debug.c
@@ -1299,10 +1299,11 @@ do_set_var(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
arg = arg->next;
val = arg->a_node;
lhs = get_field(field_num, &assign);
- unref(*lhs);
- *lhs = dupnode(val);
if (assign)
+ /* call assign to copy fields before unref frees $0 */
assign();
+ unref(*lhs);
+ *lhs = dupnode(val);
print_field(field_num);
}
break;