Re: BUG: Git command causes crash
On Sun, Dec 18, 2011 at 12:03:22AM -0500, Jeff King wrote:
Show 8 quoted lines
> 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.
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