summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-12-18 00:03:22 -0500
committerJunio C Hamano <gitster@pobox.com>2011-12-18 00:11:54 -0800
commit2c47789d817aaf745a5ce5d5f79619c634cc8566 (patch)
treec5a700e745a7d67910a182dbc2cd1d2aeb133c45
parent3b6aeb3cc37c8ef934850fb01e1de48e12cf3aac (diff)
downloadgit-2c47789d817aaf745a5ce5d5f79619c634cc8566.tar.gz
commit, merge: 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. Fix the same issue in builtin/merge.c as well. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-commit.c2
-rw-r--r--builtin-merge.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index 7434797d1b..5b418a53f8 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -69,7 +69,7 @@ static char *cleanup_arg;
static int use_editor = 1, initial_commit, in_merge;
static const char *only_include_assumed;
-static struct strbuf message;
+static struct strbuf message = STRBUF_INIT;
static int opt_parse_m(const struct option *opt, const char *arg, int unset)
{
diff --git a/builtin-merge.c b/builtin-merge.c
index 8825dcf8d9..49e9115ec4 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -42,7 +42,7 @@ static const char * const builtin_merge_usage[] = {
static int show_diffstat = 1, option_log, squash;
static int option_commit = 1, allow_fast_forward = 1;
static int allow_trivial = 1, have_message;
-static struct strbuf merge_msg;
+static struct strbuf merge_msg = STRBUF_INIT;
static struct commit_list *remoteheads;
static unsigned char head[20], stash[20];
static struct strategy **use_strategies;