Skip to content

Commit

Permalink
Fix TArray allocating 0 bytes in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRaveYard authored and coelckers committed Mar 19, 2023
1 parent 89fb5d0 commit 9514d1b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/common/utility/tarray.h
Expand Up @@ -222,9 +222,9 @@ class TArray
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);
}
Expand Down

0 comments on commit 9514d1b

Please sign in to comment.