aboutsummaryrefslogtreecommitdiffstats
path: root/interpret.h
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2017-11-14 14:28:48 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2017-11-14 14:28:48 -0500
commit064d78b562c9670751c48673c6d1d171aff51a42 (patch)
tree8c50b4d4a4ba82be1a482ab3927dab6ded648fc7 /interpret.h
parentfe60f215f0dc446e39d69d4663cbb8c5ef406535 (diff)
downloadegawk-064d78b562c9670751c48673c6d1d171aff51a42.tar.gz
egawk-064d78b562c9670751c48673c6d1d171aff51a42.tar.bz2
egawk-064d78b562c9670751c48673c6d1d171aff51a42.zip
Fix field corruption when $0 is reassigned with open $n references.
Diffstat (limited to 'interpret.h')
-rw-r--r--interpret.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/interpret.h b/interpret.h
index 166a11e1..4b140c28 100644
--- a/interpret.h
+++ b/interpret.h
@@ -699,11 +699,16 @@ mod:
lhs = r_get_field(t1, & assign, false);
decr_sp();
DEREF(t1);
+ /*
+ * N.B. We must call assign() before unref, since
+ * we may need to copy $n values before freeing the
+ * $0 buffer.
+ */
+ assert(assign != NULL);
+ assign();
unref(*lhs);
r = POP_SCALAR();
UNFIELD(*lhs, r);
- assert(assign != NULL);
- assign();
}
break;