Skip to content

Commit

Permalink
Always clear the local buffer in ArrayBuffer (#49573)
Browse files Browse the repository at this point in the history
- SslStream was holding onto a 4K byte[] after the handshake was complete. This was because the ArrayBuffer struct doesn't clear the local buffer field in dispose. This changes that.
  • Loading branch information
davidfowl authored Mar 29, 2021
1 parent 21734a4 commit 102d1e8
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/libraries/Common/src/System/Net/ArrayBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ public void Dispose()
_activeStart = 0;
_availableStart = 0;

if (_usePool)
{
byte[] array = _bytes;
_bytes = null!;
byte[] array = _bytes;
_bytes = null!;

if (array != null)
{
ArrayPool<byte>.Shared.Return(array);
}
if (_usePool && array != null)
{
ArrayPool<byte>.Shared.Return(array);
}
}

Expand Down

0 comments on commit 102d1e8

Please sign in to comment.