vtable: Fix mismatch in new/delete size

When the component is smaller than the layout
This commit is contained in:
Olivier Goffart 2025-07-07 11:01:11 +02:00
parent 5ee506e0a8
commit 73e970b8ca

View file

@ -101,6 +101,7 @@ public:
{
if (!--inner->strong_ref) {
Layout layout = inner->vtable->drop_in_place({ inner->vtable, &inner->data });
layout.size = std::max<size_t>(layout.size, sizeof(Layout)); // because of the union
layout.size += inner->data_offset;
layout.align = std::max<size_t>(layout.align, alignof(VRcInner<VTable, Dyn>));
inner->layout = layout;