aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-08-15 23:53:43 -0700
committerChris Robinson <[email protected]>2020-08-15 23:53:43 -0700
commit34b29a48a44ebd62cb1c1745e915ee7a8de54b69 (patch)
tree2557508ec0a5227b97192c06297978ea2931352a
parent23259b48dd36ea91f3a2bddd32122b35b1469e4c (diff)
Ensure enough space is allocated for structs with a FlexArray
-rw-r--r--common/almalloc.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/common/almalloc.h b/common/almalloc.h
index a2fdd9d8..0949efdc 100644
--- a/common/almalloc.h
+++ b/common/almalloc.h
@@ -47,7 +47,10 @@ enum FamCount : size_t { };
#define DEF_FAM_NEWDEL(T, FamMem) \
static constexpr size_t Sizeof(size_t count) noexcept \
- { return decltype(FamMem)::Sizeof(count, offsetof(T, FamMem)); } \
+ { \
+ return std::max<size_t>(sizeof(T), \
+ decltype(FamMem)::Sizeof(count, offsetof(T, FamMem))); \
+ } \
\
void *operator new(size_t /*size*/, FamCount count) \
{ \