]> git.ipfire.org Git - thirdparty/git.git/blobdiff - grep.c
Merge branch 'maint-1.6.1' into maint
[thirdparty/git.git] / grep.c
diff --git a/grep.c b/grep.c
index 062b2b6f28f6332518240d2a474a7739735e1ecf..b0d992a6e0a838d0fb4e71e3a8bebe8266ed1070 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -70,6 +70,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:
@@ -82,8 +84,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;
@@ -99,6 +99,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)
@@ -386,6 +388,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);