diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-04-28 00:46:39 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-04-28 00:46:39 -0700 |
commit | b79376cdf3bd6ee922261776613d085a7b36ffd9 (patch) | |
tree | 544b5717e8c87ad8c8770273e9c79ff494441c0d /grep.c | |
parent | 47afed5dc17faf10fde18789b17cf6ebff829cf4 (diff) | |
parent | 2254da06a5473ffde973337bad2c6a96eea61e20 (diff) | |
download | git-b79376cdf3bd6ee922261776613d085a7b36ffd9.tar.gz |
Merge branch 'maint'
* maint:
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.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -72,6 +72,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: @@ -84,8 +86,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; @@ -101,6 +101,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) @@ -372,6 +374,8 @@ static int match_expr_eval(struct grep_expr *x, char *bol, char *eol, int h = 0; regmatch_t match; + if (!x) + die("Not a valid grep expression"); switch (x->node) { case GREP_NODE_ATOM: h = match_one_pattern(x->u.atom, bol, eol, ctx, &match, 0); |