aboutsummaryrefslogtreecommitdiff
path: root/testdir/T.argv
diff options
context:
space:
mode:
Diffstat (limited to 'testdir/T.argv')
-rwxr-xr-xtestdir/T.argv23
1 files changed, 23 insertions, 0 deletions
diff --git a/testdir/T.argv b/testdir/T.argv
index 55e2754cd8b5..2002d3cb28c1 100755
--- a/testdir/T.argv
+++ b/testdir/T.argv
@@ -148,3 +148,26 @@ END {
printf("ARGV[%d] is %s\n", i, ARGV[i])
}' >foo2
diff foo1 foo2 || echo 'BAD: T.argv delete ARGV[2]'
+
+# deleting ARGV used to trigger a use-after-free crash when awk
+# iterates over it to read files.
+echo >foo1
+echo >foo2
+echo >foo3
+
+$awk 'BEGIN {
+ delete ARGV
+ ARGV[0] = "awk"
+ ARGV[1] = "/dev/null"
+ ARGC = 2
+} {
+ # this should not be executed
+ print "FILENAME: " FILENAME
+ fflush()
+}' foo1 foo2 foo3 >foo4
+
+awkstatus=$?
+diff /dev/null foo4
+if [ $? -ne 0 ] || [ $awkstatus -ne 0 ]; then
+ echo 'BAD: T.argv delete ARGV'
+fi