Skip to content

Commit 43acff3

Browse files
jrngitster
authored andcommitted
cherry-pick: do not dump core when iconv fails
When cherry-picking, usually the new and old commit encodings are both UTF-8. Most old iconv implementations do not support this trivial conversion, so on old platforms, out->message remains NULL, and later attempts to read it segfault. Fix this by noticing the input and output encodings match and skipping the iconv step, like the other reencode_string() call sites already do. Also stop segfaulting on other iconv failures: if iconv fails for some other reason, the best we can do is to pass the old message through. This fixes a regression introduced in v1.7.1-rc0~15^2~2 (revert: clarify label on conflict hunks, 2010-03-20). Reported-by: Andreas Krey <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e5bd0a1 commit 43acff3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

builtin/revert.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ static int get_message(const char *raw_message, struct commit_message *out)
109109
encoding = "UTF-8";
110110
if (!git_commit_encoding)
111111
git_commit_encoding = "UTF-8";
112-
if ((out->reencoded_message = reencode_string(raw_message,
113-
git_commit_encoding, encoding)))
112+
113+
out->reencoded_message = NULL;
114+
out->message = raw_message;
115+
if (strcmp(encoding, git_commit_encoding))
116+
out->reencoded_message = reencode_string(raw_message,
117+
git_commit_encoding, encoding);
118+
if (out->reencoded_message)
114119
out->message = out->reencoded_message;
115120

116121
abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);

0 commit comments

Comments
 (0)