From 6be470813136d1ca2f0f415b14a6913be37482c3 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 12 Sep 2023 23:25:14 +0100 Subject: [PATCH] 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 --- src/3rdparty/cpp-btree/btree.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/cpp-btree/btree.h b/src/3rdparty/cpp-btree/btree.h index 191497b4d2..772ad02bc5 100644 --- a/src/3rdparty/cpp-btree/btree.h +++ b/src/3rdparty/cpp-btree/btree.h @@ -1281,7 +1281,8 @@ class btree : public Params::key_compare { } node_type* new_leaf_node(node_type *parent) { leaf_fields *p = reinterpret_cast( - 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) {