this patch fixes two memory leaks in update-cache.c: we didnt free the
temporary input and output buffers used for compression.
Ingo
Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
--- update-cache.c.orig
+++ update-cache.c
@@ -23,13 +23,17 @@ static int index_fd(const char *path, in
void *metadata = malloc(namelen + 200);
void *in;
SHA_CTX c;
+ int ret;
in = "";
if (size)
in = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
- if (!out || (int)(long)in == -1)
+ if (!out || (int)(long)in == -1) {
+ free(out);
+ free(metadata);
return -1;
+ }
memset(&stream, 0, sizeof(stream));
deflateInit(&stream, Z_BEST_COMPRESSION);
@@ -58,7 +62,12 @@ static int index_fd(const char *path, in
SHA1_Update(&c, out, stream.total_out);
SHA1_Final(ce->sha1, &c);
- return write_sha1_buffer(ce->sha1, out, stream.total_out);
+ ret = write_sha1_buffer(ce->sha1, out, stream.total_out);
+
+ free(out);
+ free(metadata);
+
+ return ret;
}
/*
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html