From d5d745f90b929310f3893bb8b3766cc1745140c8 Mon Sep 17 00:00:00 2001 From: Olivier Marin Date: Mon, 21 Jul 2008 20:30:36 +0200 Subject: 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 Acked-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- parse-options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'parse-options.c') diff --git a/parse-options.c b/parse-options.c index 987b01571..71a7acf4e 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 -- cgit v1.2.1