Skip to content

Commit

Permalink
commit, merge: initialize static strbuf
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Dec 18, 2011
1 parent 3b6aeb3 commit 2c47789
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion builtin-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2c47789

Please sign in to comment.