summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2022-03-20 09:43:30 -0700
committerJim Meyering <meyering@fb.com>2022-03-20 13:23:58 -0700
commit6e95551ad6a1e5591ea0d417c2d3eec1921e48b5 (patch)
tree0cd066f97421a57350bb7b1f1b7d3bb9b4cea7f9 /tests
parentefe1e1543c409504752f8d240d3ea41af3b8fddf (diff)
downloadgrep-6e95551ad6a1e5591ea0d417c2d3eec1921e48b5.tar.gz
grep: very long lines no longer evoke unwarranted "memory exhausted"
When calling xpalloc (NULL, &n, incr_min, alloc_max, 1) with nontrivial ALLOC_MAX, this must hold: N + INCR_MIN <= ALLOC_MAX. With a very long line, it did not, and grep would mistakenly fail with a report of "memory exhausted". * src/grep.c (fillbuf): When using nontrivial ALLOC_MAX, ensure it is at least N+INCR_MIN. * tests/fillbuf-long-line: New file, to test for this. * tests/Makefile.am (TESTS): Add its name.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rwxr-xr-xtests/fillbuf-long-line11
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 04a9eeef..708980df 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -104,6 +104,7 @@ TESTS = \
fgrep-longest \
file \
filename-lineno.pl \
+ fillbuf-long-line \
fmbtest \
foad1 \
grep-dev-null \
diff --git a/tests/fillbuf-long-line b/tests/fillbuf-long-line
new file mode 100755
index 00000000..5a8d339f
--- /dev/null
+++ b/tests/fillbuf-long-line
@@ -0,0 +1,11 @@
+#!/bin/sh
+# This would fail for v3.7-15-ge3694e9 .. grep-v3.7-48-g5c3c427
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+printf %0104681d 0 > in || framework_failure_
+
+fail=0
+
+returns_ 1 grep xx in || fail=1
+
+Exit $fail