summaryrefslogtreecommitdiff
path: root/usr.bin/awk/run.c
diff options
context:
space:
mode:
authorFrederic Cambus <fcambus@cvs.openbsd.org>2019-08-13 10:41:34 +0000
committerFrederic Cambus <fcambus@cvs.openbsd.org>2019-08-13 10:41:34 +0000
commitf9da0683dea56d424014beab8f76579e1b2b21b1 (patch)
treecd5d373a2afba85b19a4b8b44feabe223d50a93c /usr.bin/awk/run.c
parent45ca2820e275eb5162369cb5950012bd34cc3879 (diff)
Fix a segmentation fault in awk, from upstream version 20121220.
OK millert@
Diffstat (limited to 'usr.bin/awk/run.c')
-rw-r--r--usr.bin/awk/run.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c
index 17dcf0cf3e6..d8d785be63c 100644
--- a/usr.bin/awk/run.c
+++ b/usr.bin/awk/run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: run.c,v 1.42 2017/10/09 14:51:31 deraadt Exp $ */
+/* $OpenBSD: run.c,v 1.43 2019/08/13 10:41:33 fcambus Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -1217,13 +1217,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;
@@ -1343,6 +1343,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);
}