ref: 9ab4f2a2428ef5ad2f4abc118f589bd70f6c2f90
parent: 27a63ae22975171efbee5549d100f416ccb4066a
author: Jacob Moody <[email protected]>
date: Wed Apr 5 22:50:09 EDT 2023
awk: dont leak memory on extra format arguments awk 'BEGIN { while(++i <= 100000) { mem = "ps | grep awk"; printf("%d", 1+2, 3+4, 5+6, 7+8, 9+0) > "/dev/null"; if(i % 10000 == 0) system(mem) }}' https://github.com/onetrueawk/awk/commit/821c502359855d0c43be8e9b08f037ecb543d310
--- a/sys/src/cmd/awk/run.c
+++ b/sys/src/cmd/awk/run.c
@@ -973,8 +973,11 @@
}
*p = '\0';
free(fmt);
- for ( ; a; a = a->nnext) /* evaluate any remaining args */
- execute(a);
+ for ( ; a; a = a->nnext) { /* evaluate any remaining args */
+ x = execute(a);
+ if (istemp(x))
+ tfree(x);
+ }
*pbuf = buf;
*pbufsize = bufsize;
return p - buf;