From c7f86efb13815554d5b5e7c58bf19769e99c1357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 26 Apr 2014 18:04:43 +0200 Subject: [PATCH 1/2] zstream: grow based on used memory rather than allocated When deflating data, we might need to grow the buffer. Currently we add a guess on top of the currently-allocated buffer size. When we re-use the buffer, it already has some memory allocated; adding to that means that we always grow the buffer regardless of how much we need to use. Instead, increase on top of the currently-used size. This still leaves us with the allocated size of the largest object we compress, but it's a minor pain compared to unbounded growth. This fixes #2285. --- src/zstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zstream.c b/src/zstream.c index 85fa2e0e6..e75fb265e 100644 --- a/src/zstream.c +++ b/src/zstream.c @@ -134,7 +134,7 @@ int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len) while (!git_zstream_done(&zs)) { size_t step = git_zstream_suggest_output_len(&zs), written; - if ((error = git_buf_grow(out, out->asize + step)) < 0) + if ((error = git_buf_grow(out, out->size + step)) < 0) goto done; written = out->asize - out->size; From 38d338b2b85f280fe54057375fc3ccd6d2877e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 26 Apr 2014 18:15:39 +0200 Subject: [PATCH 2/2] pack-objects: always write out the status in write_one() Make sure we set the output parameter to a value. --- src/pack-objects.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pack-objects.c b/src/pack-objects.c index 7e5f667f4..ace8afd17 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -406,6 +406,7 @@ static int write_one( po->delta = NULL; } + *status = WRITE_ONE_WRITTEN; po->written = 1; po->recursing = 0;