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
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,21 @@ private unsafe void UnsafeDeflate(ReadOnlySpan<byte> input, Span<byte> output, o
consumed = input.Length - (int)_stream.AvailIn;
written = output.Length - (int)_stream.AvailOut;

needsMoreBuffer = errorCode == ErrorCode.BufError || _stream.AvailIn > 0;
// It is important here to also check that we haven't
// exhausted the output buffer because after deflating we're
// always going to issue a flush and a flush with empty output
// is going to throw.
needsMoreBuffer = errorCode == ErrorCode.BufError
|| _stream.AvailIn > 0
|| written == output.Length;
}
}

private unsafe int UnsafeFlush(Span<byte> output, out bool needsMoreBuffer)
{
Debug.Assert(_stream is not null);
Debug.Assert(_stream.AvailIn == 0);
Debug.Assert(output.Length > 0);

fixed (byte* fixedOutput = output)
{
Expand Down