提交 2254da06 编写于 作者: J Junio C Hamano

Merge branch 'maint-1.6.1' into maint

* maint-1.6.1:
  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
...@@ -37,7 +37,7 @@ where options is the bitwise-or of: ...@@ -37,7 +37,7 @@ where options is the bitwise-or of:
Make sure there is a work tree, i.e. the command cannot act Make sure there is a work tree, i.e. the command cannot act
on bare repositories. on bare repositories.
This makes only sense when `RUN_SETUP` is also set. This only makes sense when `RUN_SETUP` is also set.
. Add `builtin-foo.o` to `BUILTIN_OBJS` in `Makefile`. . Add `builtin-foo.o` to `BUILTIN_OBJS` in `Makefile`.
......
...@@ -765,7 +765,7 @@ static int suggest_conflicts(void) ...@@ -765,7 +765,7 @@ static int suggest_conflicts(void)
fp = fopen(git_path("MERGE_MSG"), "a"); fp = fopen(git_path("MERGE_MSG"), "a");
if (!fp) if (!fp)
die("Could open %s for writing", git_path("MERGE_MSG")); die("Could not open %s for writing", git_path("MERGE_MSG"));
fprintf(fp, "\nConflicts:\n"); fprintf(fp, "\nConflicts:\n");
for (pos = 0; pos < active_nr; pos++) { for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos]; struct cache_entry *ce = active_cache[pos];
......
...@@ -70,6 +70,8 @@ static struct grep_expr *compile_pattern_atom(struct grep_pat **list) ...@@ -70,6 +70,8 @@ static struct grep_expr *compile_pattern_atom(struct grep_pat **list)
struct grep_expr *x; struct grep_expr *x;
p = *list; p = *list;
if (!p)
return NULL;
switch (p->token) { switch (p->token) {
case GREP_PATTERN: /* atom */ case GREP_PATTERN: /* atom */
case GREP_PATTERN_HEAD: case GREP_PATTERN_HEAD:
...@@ -82,8 +84,6 @@ static struct grep_expr *compile_pattern_atom(struct grep_pat **list) ...@@ -82,8 +84,6 @@ static struct grep_expr *compile_pattern_atom(struct grep_pat **list)
case GREP_OPEN_PAREN: case GREP_OPEN_PAREN:
*list = p->next; *list = p->next;
x = compile_pattern_or(list); x = compile_pattern_or(list);
if (!x)
return NULL;
if (!*list || (*list)->token != GREP_CLOSE_PAREN) if (!*list || (*list)->token != GREP_CLOSE_PAREN)
die("unmatched parenthesis"); die("unmatched parenthesis");
*list = (*list)->next; *list = (*list)->next;
...@@ -99,6 +99,8 @@ static struct grep_expr *compile_pattern_not(struct grep_pat **list) ...@@ -99,6 +99,8 @@ static struct grep_expr *compile_pattern_not(struct grep_pat **list)
struct grep_expr *x; struct grep_expr *x;
p = *list; p = *list;
if (!p)
return NULL;
switch (p->token) { switch (p->token) {
case GREP_NOT: case GREP_NOT:
if (!p->next) if (!p->next)
...@@ -386,6 +388,8 @@ static int match_expr_eval(struct grep_opt *o, ...@@ -386,6 +388,8 @@ static int match_expr_eval(struct grep_opt *o,
{ {
int h = 0; int h = 0;
if (!x)
die("Not a valid grep expression");
switch (x->node) { switch (x->node) {
case GREP_NODE_ATOM: case GREP_NODE_ATOM:
h = match_one_pattern(o, x->u.atom, bol, eol, ctx); h = match_one_pattern(o, x->u.atom, bol, eol, ctx);
......
...@@ -26,6 +26,10 @@ test_expect_success setup ' ...@@ -26,6 +26,10 @@ test_expect_success setup '
git commit -m initial git commit -m initial
' '
test_expect_success 'grep should not segfault with a bad input' '
test_must_fail git grep "("
'
for H in HEAD '' for H in HEAD ''
do do
case "$H" in case "$H" in
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册