From 1e6ab794fe9551b1d412351bf43ab03d4e59e0ec Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 29 May 2022 15:01:39 -0700 Subject: [PATCH] fix: Fixes ValueStringBuilder dispose incorrectly (#1037) --- Projects/Server/Buffers/ValueStringBuilder.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Projects/Server/Buffers/ValueStringBuilder.cs b/Projects/Server/Buffers/ValueStringBuilder.cs index ecc714ee3..e97ac7622 100644 --- a/Projects/Server/Buffers/ValueStringBuilder.cs +++ b/Projects/Server/Buffers/ValueStringBuilder.cs @@ -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