Skip to content

Commit e600592

Browse files
sunshinecogitster
authored andcommitted
builtin/blame: destroy initialized commit_info only
Since ea02ffa (mailmap: simplify map_user() interface, 2013-01-05), find_alignment() has been invoking commit_info_destroy() on an uninitialized auto 'struct commit_info' (when METAINFO_SHOWN is not set). commit_info_destroy() calls strbuf_release() for each 'commit_info' strbuf member, which randomly invokes free() on whatever random stack value happens to reside in strbuf.buf, thus leading to periodic crashes. Reported-by: Dilyan Palauzov <[email protected]> Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3d8a54e commit e600592

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

builtin/blame.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,6 @@ static void find_alignment(struct scoreboard *sb, int *option)
18431843

18441844
for (e = sb->ent; e; e = e->next) {
18451845
struct origin *suspect = e->suspect;
1846-
struct commit_info ci;
18471846
int num;
18481847

18491848
if (compute_auto_abbrev)
@@ -1854,6 +1853,7 @@ static void find_alignment(struct scoreboard *sb, int *option)
18541853
if (longest_file < num)
18551854
longest_file = num;
18561855
if (!(suspect->commit->object.flags & METAINFO_SHOWN)) {
1856+
struct commit_info ci;
18571857
suspect->commit->object.flags |= METAINFO_SHOWN;
18581858
get_commit_info(suspect->commit, &ci, 1);
18591859
if (*option & OUTPUT_SHOW_EMAIL)
@@ -1862,6 +1862,7 @@ static void find_alignment(struct scoreboard *sb, int *option)
18621862
num = utf8_strwidth(ci.author.buf);
18631863
if (longest_author < num)
18641864
longest_author = num;
1865+
commit_info_destroy(&ci);
18651866
}
18661867
num = e->s_lno + e->num_lines;
18671868
if (longest_src_lines < num)
@@ -1871,8 +1872,6 @@ static void find_alignment(struct scoreboard *sb, int *option)
18711872
longest_dst_lines = num;
18721873
if (largest_score < ent_score(sb, e))
18731874
largest_score = ent_score(sb, e);
1874-
1875-
commit_info_destroy(&ci);
18761875
}
18771876
max_orig_digits = decimal_width(longest_src_lines);
18781877
max_digits = decimal_width(longest_dst_lines);

0 commit comments

Comments
 (0)