Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/metaUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,29 @@ MET_PerformUncompression(const unsigned char * sourceCompressed,
}
} while (d_stream.avail_out == 0);
} while (err != Z_STREAM_END && err >= 0);
// The output buffer can fill before the trailer arrives in a later input
// chunk; keep feeding input so zlib can reach the CRC and report stream end.
unsigned char trailerScratch[1];
while (err == Z_BUF_ERROR && dest_pos == uncompressedDataSize)
{
if (d_stream.avail_in == 0)
{
if (source_pos >= sourceCompressedSize)
{
break;
}
d_stream.next_in = const_cast<unsigned char *>(sourceCompressed + source_pos);
d_stream.avail_in = static_cast<uInt>(std::min(sourceCompressedSize - source_pos, max_chunk_size));
source_pos += d_stream.avail_in;
}
d_stream.next_out = trailerScratch;
d_stream.avail_out = 1;
err = inflate(&d_stream, Z_NO_FLUSH);
if (d_stream.avail_out == 0)
{
break;
}
}
inflateEnd(&d_stream);
if (err != Z_STREAM_END)
{
Expand Down
Loading