Upgrade one-true-awk to 9e248c317b88470fc86aa7c988919dc49452c88c am: fbf461f5d4 am: 05af1187ef am: 4f2c842ed4

Original change: https://android-review.googlesource.com/c/platform/external/one-true-awk/+/2215702

Change-Id: I254f46579beb53b01ee1944514dce468c0ced898
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/FIXES b/FIXES
index ec76a4e..fdf782e 100644
--- a/FIXES
+++ b/FIXES
@@ -25,6 +25,11 @@
 This file lists all bug fixes, changes, etc., made since the AWK book
 was sent to the printers in August 1987.
 
+Sep 12, 2022:
+	adjbuf minlen error (cannot be 0) in cat, resulting in NULL pbuf.
+	discovered by todd miller. also use-after-free issue with
+	tempfree in cat, thanks to Miguel Pineiro Jr and valgrind.
+
 Aug 30, 2022:
 	Various leaks and use-after-free issues plugged/fixed.
 	Thanks to Miguel Pineiro Jr. <mpj@pineiro.cc>.
diff --git a/METADATA b/METADATA
index 69aefd3..fc82b16 100644
--- a/METADATA
+++ b/METADATA
@@ -5,11 +5,11 @@
     type: GIT
     value: "https://github.com/onetrueawk/awk.git"
   }
-  version: "30791e0f686010b39c1ab2121df85da180960d53"
+  version: "9e248c317b88470fc86aa7c988919dc49452c88c"
   license_type: NOTICE
   last_upgrade_date {
     year: 2022
-    month: 8
-    day: 31
+    month: 9
+    day: 12
   }
 }
diff --git a/main.c b/main.c
index 7b5af9e..f0b8608 100644
--- a/main.c
+++ b/main.c
@@ -22,7 +22,7 @@
 THIS SOFTWARE.
 ****************************************************************/
 
-const char	*version = "version 20220830";
+const char	*version = "version 20220912";
 
 #define DEBUG
 #include <stdio.h>
diff --git a/run.c b/run.c
index d753e42..483b9d9 100644
--- a/run.c
+++ b/run.c
@@ -1197,16 +1197,17 @@
 
 	x = execute(a[0]);
 	n1 = strlen(getsval(x));
-	adjbuf(&s, &ssz, n1, recsize, 0, "cat1");
+	adjbuf(&s, &ssz, n1 + 1, recsize, 0, "cat1");
 	memcpy(s, x->sval, n1);
 
+	tempfree(x);
+
 	y = execute(a[1]);
 	n2 = strlen(getsval(y));
 	adjbuf(&s, &ssz, n1 + n2 + 1, recsize, 0, "cat2");
 	memcpy(s + n1, y->sval, n2);
 	s[n1 + n2] = '\0';
 
-	tempfree(x);
 	tempfree(y);
 
 	z = gettemp();
diff --git a/tran.c b/tran.c
index c396db4..e1496cd 100644
--- a/tran.c
+++ b/tran.c
@@ -563,7 +563,6 @@
 
 char *qstring(const char *is, int delim)	/* collect string up to next delim */
 {
-	const char *os = is;
 	int c, n;
 	const uschar *s = (const uschar *) is;
 	uschar *buf, *bp;
@@ -572,7 +571,7 @@
 		FATAL( "out of space in qstring(%s)", s);
 	for (bp = buf; (c = *s) != delim; s++) {
 		if (c == '\n')
-			SYNTAX( "newline in string %.20s...", os );
+			SYNTAX( "newline in string %.20s...", is );
 		else if (c != '\\')
 			*bp++ = c;
 		else {	/* \something */