From e0be4e202a63eb746f3f2deedd46c2d6dfd4fb99 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 13 Jul 2021 18:28:02 +0200 Subject: [PATCH] Fix crash when resizing Dictionary to 0 --- Source/Engine/Core/Collections/Dictionary.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Core/Collections/Dictionary.h b/Source/Engine/Core/Collections/Dictionary.h index ab3e986d4..a1361dc59 100644 --- a/Source/Engine/Core/Collections/Dictionary.h +++ b/Source/Engine/Core/Collections/Dictionary.h @@ -512,10 +512,13 @@ public: capacity |= capacity >> 16; capacity = capacity + 1; } - _allocation.Allocate(capacity); - Bucket* data = _allocation.Get(); - for (int32 i = 0; i < capacity; i++) - data[i]._state = Bucket::Empty; + if (capacity) + { + _allocation.Allocate(capacity); + Bucket* data = _allocation.Get(); + for (int32 i = 0; i < capacity; i++) + data[i]._state = Bucket::Empty; + } _size = capacity; Bucket* oldData = oldAllocation.Get(); if (oldElementsCount != 0 && preserveContents)