overlaytopleft/games-fps/gzdoom/files/0041-Fix-TArray-allocating-0-bytes-in-constructor.patch

30 lines
883 B
Diff

From d028abc06403377b564623479bd830d8174455ac Mon Sep 17 00:00:00 2001
From: RaveYard <MrRaveYard@gmail.com>
Date: Sun, 19 Mar 2023 01:43:24 +0100
Subject: [PATCH 41/51] 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 a7decd4f3..8d7037db2 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);
}
--
2.39.3