summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-07-13 16:52:53 -0700
committerJunio C Hamano <gitster@pobox.com>2021-07-13 16:52:53 -0700
commit1157618a2ae50ae611ca22ce1833760bc0456156 (patch)
tree7e0a1cbd4401c16d93a82981a385726655cc052c /grep.c
parent21ef7ee4d6104c35fc6753da5406c842fb2d9286 (diff)
parentfe7fe62d8da0949d9b2bca34467b349bd294e91b (diff)
downloadgit-1157618a2ae50ae611ca22ce1833760bc0456156.tar.gz
Merge branch 'rs/grep-parser-fix'
"git grep --and -e foo" ought to have been diagnosed as an error but instead segfaulted, which has been corrected. * rs/grep-parser-fix: grep: report missing left operand of --and
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/grep.c b/grep.c
index 8f91af1cb0..424a39591b 100644
--- a/grep.c
+++ b/grep.c
@@ -657,6 +657,8 @@ static struct grep_expr *compile_pattern_and(struct grep_pat **list)
x = compile_pattern_not(list);
p = *list;
if (p && p->token == GREP_AND) {
+ if (!x)
+ die("--and not preceded by pattern expression");
if (!p->next)
die("--and not followed by pattern expression");
*list = p->next;