未验证 提交 2cbde409 编写于 作者: I Ivan Zlatanov 提交者: GitHub

Fixing a possible null reference error in WebSocket deflate. (#62428)

Fixes #62422
上级 a9fee6d5
......@@ -144,7 +144,13 @@ 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;
}
}
......@@ -152,6 +158,7 @@ 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)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册