cpp-btreee: Fix alloc/dealloc size mismatch (struct padding)

Between new_leaf_node and delete_leaf_node
This is mostly harmless, but triggers AddressSanitizer

When alignof(value_type) is less than alignof(base_fields)
and kNodeValues * sizeof(value_type) is not an integral multiple
of alignof(base_fields), such that leaf_fields has padding
This commit is contained in:
Jonathan G Rennison 2023-09-12 23:25:14 +01:00
parent c8817d7f4e
commit 6be4708131

View File

@ -1281,7 +1281,8 @@ class btree : public Params::key_compare {
}
node_type* new_leaf_node(node_type *parent) {
leaf_fields *p = reinterpret_cast<leaf_fields*>(
mutable_internal_allocator()->allocate(sizeof(leaf_fields)));
mutable_internal_allocator()->allocate(
sizeof(base_fields) + kNodeValues * sizeof(value_type)));
return node_type::init_leaf(p, parent, kNodeValues);
}
node_type* new_leaf_root_node(int max_count) {