summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-04-28 00:46:20 -0700
committerJunio C Hamano <gitster@pobox.com>2009-04-28 00:46:20 -0700
commit3e73cb2f48cc4044905455a9936692f967a0f9b3 (patch)
tree9b4030b25e8b69e40f5de0ec00dd1ba2465a2f44 /grep.c
parentcc137194519a8ddbc0514da088fb012bea40df51 (diff)
parentc922b01f54c4bebe84daeacf014cfbc8dc68479b (diff)
downloadgit-3e73cb2f48cc4044905455a9936692f967a0f9b3.tar.gz
Merge branch 'maint-1.6.0' into maint-1.6.1
* maint-1.6.0: grep: fix segfault when "git grep '('" is given Documentation: fix a grammatical error in api-builtin.txt builtin-merge: fix a typo in an error message
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index 600f69f2fe..704facf996 100644
--- a/grep.c
+++ b/grep.c
@@ -54,6 +54,8 @@ static struct grep_expr *compile_pattern_atom(struct grep_pat **list)
struct grep_expr *x;
p = *list;
+ if (!p)
+ return NULL;
switch (p->token) {
case GREP_PATTERN: /* atom */
case GREP_PATTERN_HEAD:
@@ -66,8 +68,6 @@ static struct grep_expr *compile_pattern_atom(struct grep_pat **list)
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;
@@ -83,6 +83,8 @@ static struct grep_expr *compile_pattern_not(struct grep_pat **list)
struct grep_expr *x;
p = *list;
+ if (!p)
+ return NULL;
switch (p->token) {
case GREP_NOT:
if (!p->next)
@@ -368,6 +370,8 @@ static int match_expr_eval(struct grep_opt *o,
{
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);