From 6e4554b7d503404f5af8da020de1125c69a20ce8 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 10 Dec 2012 07:20:00 +0100 Subject: awk: prevent split(a[x], a) from freeing a[x] the freesymtab() call frees the y argument. temporarily mark it not to be freed. --- sys/src/cmd/awk/run.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/src/cmd/awk/run.c b/sys/src/cmd/awk/run.c index 5f094629e..86498f197 100644 --- a/sys/src/cmd/awk/run.c +++ b/sys/src/cmd/awk/run.c @@ -1213,7 +1213,9 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ 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; -- cgit v1.2.3