Skip to content

Commit 2c47789

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b6aeb3 commit 2c47789

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

builtin-commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static char *cleanup_arg;
6969

7070
static int use_editor = 1, initial_commit, in_merge;
7171
static const char *only_include_assumed;
72-
static struct strbuf message;
72+
static struct strbuf message = STRBUF_INIT;
7373

7474
static int opt_parse_m(const struct option *opt, const char *arg, int unset)
7575
{

builtin-merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const char * const builtin_merge_usage[] = {
4242
static int show_diffstat = 1, option_log, squash;
4343
static int option_commit = 1, allow_fast_forward = 1;
4444
static int allow_trivial = 1, have_message;
45-
static struct strbuf merge_msg;
45+
static struct strbuf merge_msg = STRBUF_INIT;
4646
static struct commit_list *remoteheads;
4747
static unsigned char head[20], stash[20];
4848
static struct strategy **use_strategies;

0 commit comments

Comments
 (0)