Code

Merge branch 'post1.5.1/blame.el'
[git.git] / builtin-rerere.c
index b8867ab4add83dee4ab99108e96949bcd65290a0..b463c07f04b127ee3d1e17962813367fb4a5a588 100644 (file)
@@ -78,6 +78,13 @@ static void append_line(struct buffer *buffer, const char *line)
        buffer->nr += len;
 }
 
+static void clear_buffer(struct buffer *buffer)
+{
+       free(buffer->ptr);
+       buffer->ptr = NULL;
+       buffer->nr = buffer->alloc = 0;
+}
+
 static int handle_file(const char *path,
         unsigned char *sha1, const char *output)
 {
@@ -131,6 +138,8 @@ static int handle_file(const char *path,
                                SHA1_Update(&ctx, two->ptr, two->nr);
                                SHA1_Update(&ctx, "\0", 1);
                        }
+                       clear_buffer(one);
+                       clear_buffer(two);
                } else if (hunk == 1)
                        append_line(one, buf);
                else if (hunk == 2)