Skip to content

Commit

Permalink
Handle invalid argc gently
Browse files Browse the repository at this point in the history
describe, git: Handle argc==0 case the same way as argc==1.
merge-tree: Refuse excessive arguments.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Dmitry V. Levin authored and Junio C Hamano committed Sep 14, 2006
1 parent 7977f0e commit 5b6df8e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int main(int argc, char **argv)

setup_git_directory();

if (i == argc)
if (argc <= i)
describe("HEAD", 1);
else
while (i < argc) {
Expand Down
2 changes: 1 addition & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)

int main(int argc, const char **argv, char **envp)
{
const char *cmd = argv[0];
const char *cmd = argv[0] ? argv[0] : "git-help";
char *slash = strrchr(cmd, '/');
const char *exec_path = NULL;
int done_alias = 0;
Expand Down
2 changes: 1 addition & 1 deletion merge-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ int main(int argc, char **argv)
struct tree_desc t[3];
void *buf1, *buf2, *buf3;

if (argc < 4)
if (argc != 4)
usage(merge_tree_usage);

setup_git_directory();
Expand Down

0 comments on commit 5b6df8e

Please sign in to comment.