summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorOlivier Marin <dkr@freesurf.fr>2008-07-21 20:30:36 +0200
committerJunio C Hamano <gitster@pobox.com>2008-07-21 21:20:04 -0700
commitd5d745f90b929310f3893bb8b3766cc1745140c8 (patch)
treede67ef03b447f77d5484f45b2288b73dede8383b /parse-options.c
parent0d4ede9f5493f0e15fb4f799e6a4a25e36c49fd2 (diff)
downloadgit-d5d745f90b929310f3893bb8b3766cc1745140c8.tar.gz
parse-options: fix segmentation fault when a required value is missing
p->argc represent the number of arguments that have not been parsed yet, _including_ the one we are currently parsing. If it is not greater than one then there is no more argument. Signed-off-by: Olivier Marin <dkr@freesurf.fr> Acked-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/parse-options.c b/parse-options.c
index 987b015719..71a7acf4e2 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -22,7 +22,7 @@ static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt,
p->opt = NULL;
} else if (p->argc == 1 && (opt->flags & PARSE_OPT_LASTARG_DEFAULT)) {
*arg = (const char *)opt->defval;
- } else if (p->argc) {
+ } else if (p->argc > 1) {
p->argc--;
*arg = *++p->argv;
} else