提交 2c47789d 编写于 作者: J Jeff King 提交者: Junio C Hamano

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: NJeff King <peff@peff.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 3b6aeb3c
......@@ -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)
{
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册