From: Pierre Habouzit <madcoder@debian.org>
To: Olivier Marin <dkr+ml.git@free.fr>
Cc: Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] parse-options: fix segmentation fault when a required value is missing
Date: Mon, 21 Jul 2008 21:07:10 +0200 [thread overview]
Message-ID: <20080721190709.GD2718@artemis.madism.org> (raw)
In-Reply-To: <4884D5CC.2070007@free.fr>
[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]
On Mon, Jul 21, 2008 at 06:30:36PM +0000, Olivier Marin wrote:
> From: Olivier Marin <dkr@freesurf.fr>
>
> 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>
> ---
> I hope this is the right fix.
>
> parse-options.c | 2 +-
> t/t0040-parse-options.sh | 7 +++++++
> 2 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/parse-options.c b/parse-options.c
> index 987b015..71a7acf 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
Gasp thanks, Junio pointed it to me already, and for some reason this
hasn't made it.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2008-07-21 19:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-21 18:30 [PATCH] parse-options: fix segmentation fault when a required value is missing Olivier Marin
2008-07-21 19:07 ` Pierre Habouzit [this message]
2008-07-22 10:11 ` [PATCH v2] " Olivier Marin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080721190709.GD2718@artemis.madism.org \
--to=madcoder@debian.org \
--cc=dkr+ml.git@free.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.