All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Ryan O'Hara <minitech.me@gmail.com>
Cc: git <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: BUG: Git command causes crash
Date: Sun, 18 Dec 2011 00:07:28 -0500	[thread overview]
Message-ID: <20111218050728.GB1787@sigill.intra.peff.net> (raw)
In-Reply-To: <20111218050322.GA1787@sigill.intra.peff.net>

On Sun, Dec 18, 2011 at 12:03:22AM -0500, Jeff King wrote:

> Subject: [PATCH] commit: initialize static strbuf
> 
> Strbufs cannot rely on static all-zero initialization;
> instead, they must use STRBUF_INIT to point to the
> "slopbuf".
> 
> Without this patch, "git commit --no-message" segfaults
> reliably.

This one, too:

diff --git a/builtin/merge.c b/builtin/merge.c
index 2457940..28a3a7e 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -50,7 +50,7 @@ struct strategy {
 static int fast_forward_only, option_edit;
 static int allow_trivial = 1, have_message;
 static int overwrite_ignore = 1;
-static struct strbuf merge_msg;
+static struct strbuf merge_msg = STRBUF_INIT;
 static struct commit_list *remoteheads;
 static struct strategy **use_strategies;
 static size_t use_strategies_nr, use_strategies_alloc;

I'm not sure if you can actually trigger a segfault, but it clearly
violates the strbuf API.

-Peff

  reply	other threads:[~2011-12-18  5:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-18  3:13 BUG: Git command causes crash Ryan O'Hara
2011-12-18  5:03 ` Jeff King
2011-12-18  5:07   ` Jeff King [this message]
2011-12-18  5:38     ` Jeff King

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=20111218050728.GB1787@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=minitech.me@gmail.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.