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>

Jeff King committed Dec 18, 2011 at 00:03 UTC 2c47789d817aaf745a5ce5d5f79619c634cc8566
2 files changed +2 -2
builtin-commit.c
+1 -1
@@ -69,7 +69,7 @@ static char *cleanup_arg;
69
70 static int use_editor = 1, initial_commit, in_merge;
71 static const char *only_include_assumed;
72 -static struct strbuf message;
72 +static struct strbuf message = STRBUF_INIT;
73
74 static int opt_parse_m(const struct option *opt, const char *arg, int unset)
75 {
builtin-merge.c
+1 -1
@@ -42,7 +42,7 @@ static const char * const builtin_merge_usage[] = {
42 static int show_diffstat = 1, option_log, squash;
43 static int option_commit = 1, allow_fast_forward = 1;
44 static int allow_trivial = 1, have_message;
45 -static struct strbuf merge_msg;
45 +static struct strbuf merge_msg = STRBUF_INIT;
46 static struct commit_list *remoteheads;
47 static unsigned char head[20], stash[20];
48 static struct strategy **use_strategies;