fix: Fixes ValueStringBuilder dispose incorrectly (#1037)

This commit is contained in:
Kamron Batman 2022-05-29 15:01:39 -07:00 committed by GitHub
parent 3b7e3c2fb7
commit 1e6ab794fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -347,12 +347,12 @@ public ref struct ValueStringBuilder
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose()
{
char[] toReturn = _arrayToReturnToPool;
this = default; // for safety, to avoid using pooled array if this instance is erroneously appended to again
if (toReturn != null)
if (_arrayToReturnToPool != null)
{
ArrayPool.Return(toReturn);
ArrayPool.Return(_arrayToReturnToPool);
}
this = default; // for safety, to avoid using pooled array if this instance is erroneously appended to again
}
#nullable restore