Skip to content

Commit

Permalink
git-blame: prevent argument parsing segfault
Browse files Browse the repository at this point in the history
The 3rd branch in builtin-blame.c should also check for lacking
arguments.  Running that in top dir does not trigger the problem
because the 'prefix' is NULL.

Signed-off-by: Tommi Kyntola <tommi.kyntola@ray.fi>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Tommi Kyntola authored and Junio C Hamano committed Feb 17, 2007
1 parent de6f0de commit f442132
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin-blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
if (!strcmp(argv[j], "--"))
seen_dashdash = j;
if (seen_dashdash) {
/* (2) */
if (seen_dashdash + 1 != argc - 1)
usage(blame_usage);
path = add_prefix(prefix, argv[seen_dashdash + 1]);
Expand All @@ -2208,6 +2209,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
}
else {
/* (3) */
if (argc <= i)
usage(blame_usage);
path = add_prefix(prefix, argv[i]);
if (i + 1 == argc - 1) {
final_commit_name = argv[i + 1];
Expand Down

0 comments on commit f442132

Please sign in to comment.