git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petter Urkedal <urkedal@nbi.dk>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, urkedal@nbi.dk
Subject: Re: [PATCH] Reserve a slot for argv[0] in default_arg.
Date: Sun, 4 Oct 2009 16:51:41 +0200	[thread overview]
Message-ID: <20091004145141.GA16477@eideticdew.org> (raw)
In-Reply-To: <20091004133333.GA13894@sigill.intra.peff.net>

On 2009-10-04, Jeff King wrote:
> Thanks, your fix looks sane. But I am curious about whether we are
> triggering some glibc pickiness that is in your setup, or if we are
> somehow violating the assumption that we only ever look at
> default_arg[1] and beyond.

I had a look at parse-options.c.  In parse_options_start, argv is
assigned to ctx->out, which is overwritten from index 0 in
parse_options_end.  This will show the problem:

diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 3510a86..1c587ad 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -691,6 +691,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                showbranch_use_color = git_use_color_default;
 
        /* If nothing is specified, try the default first */
+       printf("default_arg = %p\n", default_arg);
        if (ac == 1 && default_num) {
                ac = default_num + 1;
                av = default_arg - 1; /* ick; we would not address av[0] */
diff --git a/parse-options.c b/parse-options.c
index f559411..267e752 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -435,6 +435,7 @@ unknown:
 
 int parse_options_end(struct parse_opt_ctx_t *ctx)
 {
+       printf("Assigning to %p\n", ctx->out + ctx->cpidx);
        memmove(ctx->out + ctx->cpidx, ctx->argv, ctx->argc * sizeof(*ctx->out));
        ctx->out[ctx->cpidx + ctx->argc] = NULL;
        return ctx->cpidx + ctx->argc;


      parent reply	other threads:[~2009-10-04 14:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-03 13:29 [PATCH] Reserve a slot for argv[0] in default_arg Petter Urkedal
2009-10-04 13:33 ` Jeff King
2009-10-04 14:13   ` Petter Urkedal
2009-10-04 18:27     ` Jeff King
2009-10-04 20:02       ` Stephen Boyd
2009-10-04 22:20       ` Junio C Hamano
2009-10-05  6:36         ` Petter Urkedal
2009-10-05 18:45           ` Jeff King
2009-10-05  6:44       ` Petter Urkedal
2009-10-04 14:51   ` Petter Urkedal [this message]

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=20091004145141.GA16477@eideticdew.org \
    --to=urkedal@nbi.dk \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).