From 51cb8afb804db8e71007fb238dab9f9ff0f09ec8 Mon Sep 17 00:00:00 2001 From: Igor Chorążewicz Date: Thu, 8 Oct 2020 12:27:12 +0200 Subject: [PATCH] radix_tree: fix internal find Fix comparison between n->byte and key.size(). When using pmem::obj::string or inline_string the behavior was ok (since we always have null terminator at the end), but we technically access out-of-range memory which can cause asserts in string_view operator[]. --- include/libpmemobj++/experimental/radix_tree.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libpmemobj++/experimental/radix_tree.hpp b/include/libpmemobj++/experimental/radix_tree.hpp index e55280c7..9fcc1a4b 100644 --- a/include/libpmemobj++/experimental/radix_tree.hpp +++ b/include/libpmemobj++/experimental/radix_tree.hpp @@ -1744,7 +1744,7 @@ radix_tree::internal_find(const K &k) const while (n && !n.is_leaf()) { if (path_length_equal(key.size(), n)) n = n->embedded_entry; - else if (n->byte > key.size()) + else if (n->byte >= key.size()) return nullptr; else n = n->child[slice_index(key[n->byte], n->bit)]; -- 2.28.0