Skip to content

Commit 1865806

Browse files
authored
Merge pull request libgit2#5740 from libgit2/ethomson/zlib
pack: continue zlib while we can make progress
2 parents 4ab9567 + 93f61c5 commit 1865806

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/pack.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ static int packfile_unpack_compressed(
908908

909909
do {
910910
size_t bytes = buffer_len - total;
911-
unsigned int window_len;
911+
unsigned int window_len, consumed;
912912
unsigned char *in;
913913

914914
if ((in = pack_window_open(p, mwindow, *position, &window_len)) == NULL) {
@@ -924,10 +924,15 @@ static int packfile_unpack_compressed(
924924

925925
git_mwindow_close(mwindow);
926926

927-
if (!bytes)
928-
break;
927+
consumed = window_len - (unsigned int)zstream.in_len;
928+
929+
if (!bytes && !consumed) {
930+
git_error_set(GIT_ERROR_ZLIB, "error inflating zlib stream");
931+
error = -1;
932+
goto out;
933+
}
929934

930-
*position += window_len - zstream.in_len;
935+
*position += consumed;
931936
total += bytes;
932937
} while (!git_zstream_eos(&zstream));
933938

0 commit comments

Comments
 (0)