Fix TArray allocating 0 bytes in constructor

This commit is contained in:
RaveYard 2023-03-19 01:43:24 +01:00 committed by Christoph Oelckers
parent 89fb5d0a92
commit 9514d1b120

View file

@ -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);
}