From 9514d1b1206d0f2e2a231a7696dae4702fdce47b Mon Sep 17 00:00:00 2001 From: RaveYard Date: Sun, 19 Mar 2023 01:43:24 +0100 Subject: [PATCH] Fix TArray allocating 0 bytes in constructor --- src/common/utility/tarray.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/utility/tarray.h b/src/common/utility/tarray.h index 61dc5e12cc..662193f393 100644 --- a/src/common/utility/tarray.h +++ b/src/common/utility/tarray.h @@ -222,9 +222,9 @@ public: explicit TArray (size_t max, bool reserve = false) { Most = (unsigned)max; - Count = (unsigned)(reserve? max : 0); - Array = (T *)M_Malloc (sizeof(T)*max); - if (reserve && Count > 0) + Count = (unsigned)(reserve ? max : 0); + Array = max > 0 ? (T *)M_Malloc (sizeof(T)*max) : nullptr; + if (Count > 0) { ConstructEmpty(0, Count - 1); }