path: root/builtin-apply.c
diff options
authorLinus Torvalds <>2009-01-08 03:54:47 (GMT)
committerJunio C Hamano <>2009-01-11 10:13:06 (GMT)
commit39c68542fc8d8477f2080c99efedb9dce975abc6 (patch)
tree20dc36a5228a41c4332ceed568254ab48d16c9df /builtin-apply.c
parent141201d124f3663a98e0f362c1af7f5f7b58dabb (diff)
Wrap inflate and other zlib routines for better error reporting
R. Tyler Ballance reported a mysterious transient repository corruption; after much digging, it turns out that we were not catching and reporting memory allocation errors from some calls we make to zlib. This one _just_ wraps things; it doesn't do the "retry on low memory error" part, at least not yet. It is an independent issue from the reporting. Some of the errors are expected and passed back to the caller, but we die when zlib reports it failed to allocate memory for now. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin-apply.c')
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin-apply.c b/builtin-apply.c
index 50b623e..eface97 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1258,8 +1258,9 @@ static char *inflate_it(const void *data, unsigned long size,
stream.avail_in = size;
stream.next_out = out = xmalloc(inflated_size);
stream.avail_out = inflated_size;
- inflateInit(&stream);
- st = inflate(&stream, Z_FINISH);
+ git_inflate_init(&stream);
+ st = git_inflate(&stream, Z_FINISH);
+ git_inflate_end(&stream);
if ((st != Z_STREAM_END) || stream.total_out != inflated_size) {
return NULL;