summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d649048)
raw | patch | inline | side by side (parent: d649048)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Mon, 27 Apr 2009 18:10:24 +0000 (11:10 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 28 Apr 2009 00:28:18 +0000 (17:28 -0700) |
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c | patch | blob | history | |
t/t7002-grep.sh | patch | blob | history |
index 13c18ff6529f437e6aea2671ab0003d4fd047ac7..a4edacad8b4e4365bc22266521e26f3b617d53b5 100644 (file)
--- a/grep.c
+++ b/grep.c
struct grep_expr *x;
p = *list;
+ if (!p)
+ return NULL;
switch (p->token) {
case GREP_PATTERN: /* atom */
case GREP_PATTERN_HEAD:
case GREP_OPEN_PAREN:
*list = p->next;
x = compile_pattern_or(list);
- if (!x)
- return NULL;
if (!*list || (*list)->token != GREP_CLOSE_PAREN)
die("unmatched parenthesis");
*list = (*list)->next;
struct grep_expr *x;
p = *list;
+ if (!p)
+ return NULL;
switch (p->token) {
case GREP_NOT:
if (!p->next)
{
int h = 0;
+ if (!x)
+ die("Not a valid grep expression");
switch (x->node) {
case GREP_NODE_ATOM:
h = match_one_pattern(o, x->u.atom, bol, eol, ctx);
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 5e359cb561b6d6f7c1bae678b7b823ed2ce34cf1..087bacb89747bb3da7fc3f7ab3fe08bacea91d52 100755 (executable)
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
git commit -m initial
'
+test_expect_success 'grep should not segfault with a bad input' '
+ test_must_fail git grep "("
+'
+
for H in HEAD ''
do
case "$H" in