The option checking code for --git-dir had an off by 1 error that would cause it to access uninitialized memory if it was the last argument. This causes it to display an error and display the usage string instead. Signed-off-by: Brian Gernhardt <benji@xxxxxxxxxxxxxxxxxx> --- I would have made this display the git directory, but the code to do that seems to be unique to rev-parse and involve more set up than is done at the time the option is parsed. git.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/git.c b/git.c index 73cf4d4..2b3c9f9 100644 --- a/git.c +++ b/git.c @@ -59,11 +59,14 @@ static int handle_options(const char*** argv, int* argc) } else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) { setup_pager(); } else if (!strcmp(cmd, "--git-dir")) { - if (*argc < 1) - return -1; - setenv("GIT_DIR", (*argv)[1], 1); - (*argv)++; - (*argc)--; + if (*argc < 2) { + fprintf(stderr, "No directory given for --git-dir.\n" ); + usage(git_usage_string); + } else { + setenv("GIT_DIR", (*argv)[1], 1); + (*argv)++; + (*argc)--; + } } else if (!strncmp(cmd, "--git-dir=", 10)) { setenv("GIT_DIR", cmd + 10, 1); } else if (!strcmp(cmd, "--bare")) { -- 1.4.4.GIT - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html