From 1ab367d63748cfafe08a051c535b4c5b83ef8f38 Mon Sep 17 00:00:00 2001 From: Stefano Merotta <97297186+stefanomerotta@users.noreply.github.com> Date: Fri, 15 Dec 2023 22:46:52 +0100 Subject: [PATCH] fix: Fixes pooled ref collections dispose on defaults (#1638) --- Projects/Server/Collections/PooledRefList.cs | 2 +- Projects/Server/Collections/PooledRefQueue.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/Server/Collections/PooledRefList.cs b/Projects/Server/Collections/PooledRefList.cs index dfde0358f5..27eba2be1f 100644 --- a/Projects/Server/Collections/PooledRefList.cs +++ b/Projects/Server/Collections/PooledRefList.cs @@ -1143,7 +1143,7 @@ public void Dispose() { var array = _items; - if (array.Length > 0) + if (array?.Length > 0) { Clear(); ArrayPool.Return(_items); diff --git a/Projects/Server/Collections/PooledRefQueue.cs b/Projects/Server/Collections/PooledRefQueue.cs index 7d9d54de4a..cef14806ac 100644 --- a/Projects/Server/Collections/PooledRefQueue.cs +++ b/Projects/Server/Collections/PooledRefQueue.cs @@ -385,7 +385,7 @@ private void Grow(int capacity) public void Dispose() { var array = _array; - if (array.Length > 0) + if (array?.Length > 0) { Clear(); (_mt ? ArrayPool.Shared : STArrayPool.Shared).Return(array);