From 34b29a48a44ebd62cb1c1745e915ee7a8de54b69 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 15 Aug 2020 23:53:43 -0700 Subject: Ensure enough space is allocated for structs with a FlexArray --- common/almalloc.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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(sizeof(T), \ + decltype(FamMem)::Sizeof(count, offsetof(T, FamMem))); \ + } \ \ void *operator new(size_t /*size*/, FamCount count) \ { \ -- cgit v1.2.3