summaryrefslogtreecommitdiffstats
path: root/contrib/one-true-awk/run.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/one-true-awk/run.c')
-rw-r--r--contrib/one-true-awk/run.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/contrib/one-true-awk/run.c b/contrib/one-true-awk/run.c
index 942f250..cafaff3 100644
--- a/contrib/one-true-awk/run.c
+++ b/contrib/one-true-awk/run.c
@@ -1213,13 +1213,13 @@ Cell *dopa2(Node **a, int n) /* a[0], a[1] { a[2] } */
Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
{
Cell *x = 0, *y, *ap;
- char *s;
+ char *s, *origs;
int sep;
char *t, temp, num[50], *fs = 0;
int n, tempstat, arg3type;
y = execute(a[0]); /* source string */
- s = getsval(y);
+ origs = s = strdup(getsval(y));
arg3type = ptoi(a[3]);
if (a[2] == 0) /* fs string */
fs = *FS;
@@ -1339,6 +1339,7 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
}
tempfree(ap);
tempfree(y);
+ free(origs);
if (a[2] != 0 && arg3type == STRING) {
tempfree(x);
}
OpenPOWER on IntegriCloud