diff options
author | Tommi Kyntola <tommi.kyntola@ray.fi> | 2007-02-16 10:50:58 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-16 21:39:21 -0800 |
commit | f44213258de3fbef932f9c655213202f69dccc80 (patch) | |
tree | 3b7a5142b1ec8fcd22531845921e6a4aaea73068 /builtin-blame.c | |
parent | de6f0def506935811384a39fb0660095f5555e68 (diff) | |
download | git-f44213258de3fbef932f9c655213202f69dccc80.tar.gz git-f44213258de3fbef932f9c655213202f69dccc80.tar.xz |
git-blame: prevent argument parsing segfault
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>
Diffstat (limited to 'builtin-blame.c')
-rw-r--r-- | builtin-blame.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin-blame.c b/builtin-blame.c index 69fc145a3..1a752b95b 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -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]); @@ -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]; |