Commit c8f16bfef992452fb4ef7622a2ecd810c1937225

schu 2011-09-09T14:05:32

filebuf.c: fix unused-but-set warning write_deflate() used to ignore errors by zlib's deflate function when not compiling in DEBUG mode. Always read $result and throw an error instead. Signed-off-by: schu <schu-github@schulog.org>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/filebuf.c b/src/filebuf.c
index e8c5087..7ec9142 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -126,7 +126,8 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
 			zs->avail_out = (uInt)file->buf_size;
 
 			result = deflate(zs, file->flush_mode);
-			assert(result != Z_STREAM_ERROR);
+			if (result == Z_STREAM_ERROR)
+				return git__throw(GIT_ERROR, "Failed to deflate input");
 
 			have = file->buf_size - (size_t)zs->avail_out;