Commit c0e16a46 by Edward Thomson

pack: continue zlib while we can make progress

Continue the zlib stream as long as we can make progress; stop when we
stop getting output _or_ when zlib stops taking input from us.
parent 97c03eae
...@@ -841,7 +841,7 @@ static int packfile_unpack_compressed( ...@@ -841,7 +841,7 @@ static int packfile_unpack_compressed(
do { do {
size_t bytes = buffer_len - total; size_t bytes = buffer_len - total;
unsigned int window_len; unsigned int window_len, consumed;
unsigned char *in; unsigned char *in;
if ((in = pack_window_open(p, mwindow, *position, &window_len)) == NULL) { if ((in = pack_window_open(p, mwindow, *position, &window_len)) == NULL) {
...@@ -857,10 +857,15 @@ static int packfile_unpack_compressed( ...@@ -857,10 +857,15 @@ static int packfile_unpack_compressed(
git_mwindow_close(mwindow); git_mwindow_close(mwindow);
if (!bytes) consumed = window_len - (unsigned int)zstream.in_len;
break;
if (!bytes && !consumed) {
git_error_set(GIT_ERROR_ZLIB, "error inflating zlib stream");
error = -1;
goto out;
}
*position += window_len - zstream.in_len; *position += consumed;
total += bytes; total += bytes;
} while (!git_zstream_eos(&zstream)); } while (!git_zstream_eos(&zstream));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment