Skip to content

Commit

Permalink
rerere: Fix use of an empty strbuf.buf
Browse files Browse the repository at this point in the history
The code incorrectly assumed that strbuf.buf is always an
allocated piece of memory that has NUL at offset strbuf.len.
That assumption does not hold for a freshly initialized empty
strbuf.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Sep 27, 2007
1 parent 1dffb8f commit b4833a2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions builtin-rerere.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ static int handle_file(const char *path,
fputs(">>>>>>>\n", out);
}
if (sha1) {
SHA1_Update(&ctx, one.buf, one.len + 1);
SHA1_Update(&ctx, two.buf, two.len + 1);
SHA1_Update(&ctx, one.buf ? one.buf : "",
one.len + 1);
SHA1_Update(&ctx, two.buf ? two.buf : "",
two.len + 1);
}
strbuf_reset(&one);
strbuf_reset(&two);
Expand Down

0 comments on commit b4833a2

Please sign in to comment.