From 345f6e2cb547007da48ef503f00070cdcca04975 Mon Sep 17 00:00:00 2001 From: Allan Caffee Date: Mon, 13 Apr 2009 14:10:08 -0400 Subject: [PATCH 1/3] builtin-merge: fix a typo in an error message Signed-off-by: Allan Caffee Acked-by: Miklos Vajna Signed-off-by: Junio C Hamano --- builtin-merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-merge.c b/builtin-merge.c index d0bf1fc1ed..370d0034ca 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -703,7 +703,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]; From d649048e68f2f5d59f6f961839c9e9772743a505 Mon Sep 17 00:00:00 2001 From: Allan Caffee Date: Mon, 13 Apr 2009 14:11:21 -0400 Subject: [PATCH 2/3] Documentation: fix a grammatical error in api-builtin.txt Signed-off-by: Allan Caffee Signed-off-by: Junio C Hamano --- Documentation/technical/api-builtin.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/technical/api-builtin.txt b/Documentation/technical/api-builtin.txt index 7ede1e64e5..5cb2b0590a 100644 --- a/Documentation/technical/api-builtin.txt +++ b/Documentation/technical/api-builtin.txt @@ -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`. From c922b01f54c4bebe84daeacf014cfbc8dc68479b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 27 Apr 2009 11:10:24 -0700 Subject: [PATCH 3/3] grep: fix segfault when "git grep '('" is given Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- grep.c | 8 ++++++-- t/t7002-grep.sh | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/grep.c b/grep.c index 13c18ff652..a4edacad8b 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) @@ -361,6 +363,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); diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index 5e359cb561..087bacb897 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -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