git: 9front

Download patch

ref: b2245e1ada3af682b032b73a232690898a6936c2
parent: 80764747b0a5bcadfd50d8391144c9f924ab4a32
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Mon Dec 10 02:20:00 EST 2012

awk: prevent split(a[x], a) from freeing a[x]

the freesymtab() call frees the y argument. temporarily mark it
not to be freed.

--- a/sys/src/cmd/awk/run.c
+++ b/sys/src/cmd/awk/run.c
@@ -1213,7 +1213,9 @@
 		FATAL("illegal type of split");
 	sep = *fs;
 	ap = execute(a[1]);	/* array name */
+	y->tval |= DONTFREE;	/* split(a[x], a); */
 	freesymtab(ap);
+	y->tval &= ~DONTFREE;
 	   dprintf( ("split: s=|%s|, a=%s, sep=|%s|\n", s, ap->nval, fs) );
 	ap->tval &= ~STR;
 	ap->tval |= ARR;
--