Skip to content

Commit

Permalink
builtin/blame.c::prepare_lines: fix allocation size of sb->lineno
Browse files Browse the repository at this point in the history
If we are calling xrealloc on every single line, the least we can do
is get the right allocation size.

Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David Kastrup authored and Junio C Hamano committed Feb 24, 2014
1 parent 0a88f08 commit 62cf3ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ static int prepare_lines(struct scoreboard *sb)
while (len--) {
if (bol) {
sb->lineno = xrealloc(sb->lineno,
sizeof(int *) * (num + 1));
sizeof(int) * (num + 1));
sb->lineno[num] = buf - sb->final_buf;
bol = 0;
}
Expand All @@ -1773,7 +1773,7 @@ static int prepare_lines(struct scoreboard *sb)
}
}
sb->lineno = xrealloc(sb->lineno,
sizeof(int *) * (num + incomplete + 1));
sizeof(int) * (num + incomplete + 1));
sb->lineno[num + incomplete] = buf - sb->final_buf;
sb->num_lines = num + incomplete;
return sb->num_lines;
Expand Down

0 comments on commit 62cf3ca

Please sign in to comment.