[PATCH 1/2] t4202: demonstrate `git log --invert-grep` segfault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When `--invert-grep` is given without a pattern, `git log` behaves as
normal. But as of f41fb662f5 (revisions API: have release_revisions()
release "grep_filter", 2022-04-13), this doesn't quite work because we
try to dereference the NULL `grep_expr` pointer in
`free_pattern_expr()`, leading to a sgefault.

The subsequent patch will explain the bug, provide a fix, and update
this test to expect success.

Signed-off-by: Taylor Blau <me@xxxxxxxxxxxx>
---
 t/t4202-log.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index cc15cb4ff6..e3ec5f5661 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -297,6 +297,12 @@ test_expect_success 'log --invert-grep --grep -i' '
 	fi
 '
 
+test_expect_failure 'log --invert-grep (no --grep)' '
+	git log --pretty="tformat:%s" >expect &&
+	git log --invert-grep --pretty="tformat:%s" >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'log --grep option parsing' '
 	echo second >expect &&
 	git log -1 --pretty="tformat:%s" --grep sec >actual &&
-- 
2.37.0.1.g1379af2e9d




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux