Skip to content

Commit

Permalink
Merge branch 'maint-1.6.1' into maint
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Apr 28, 2009
2 parents f06b9f1 + 3e73cb2 commit 2254da0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Documentation/technical/api-builtin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where options is the bitwise-or of:

Make sure there is a work tree, i.e. the command cannot act
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`.

Expand Down
2 changes: 1 addition & 1 deletion builtin-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ static int suggest_conflicts(void)

fp = fopen(git_path("MERGE_MSG"), "a");
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");
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
Expand Down
8 changes: 6 additions & 2 deletions grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions t/t7002-grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ test_expect_success setup '
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
Expand Down

0 comments on commit 2254da0

Please sign in to comment.