@matheusbsbs / matheus-bagliano / commits / b4833a2c62
Fork 0

rerere: Fix use of an empty strbuf.buf

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>

Junio C Hamano committed Sep 26, 2007 at 23:34 UTC b4833a2c62578bdbfd300e296702214cb1b9a601
1 file changed +4 -2
builtin-rerere.c
+4 -2
@@ -113,8 +113,10 @@ static int handle_file(const char *path,
113 fputs(">>>>>>>\n", out);
114 }
115 if (sha1) {
116 - SHA1_Update(&ctx, one.buf, one.len + 1);
117 - SHA1_Update(&ctx, two.buf, two.len + 1);
116 + SHA1_Update(&ctx, one.buf ? one.buf : "",
117 + one.len + 1);
118 + SHA1_Update(&ctx, two.buf ? two.buf : "",
119 + two.len + 1);
120 }
121 strbuf_reset(&one);
122 strbuf_reset(&two);