Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 51cb8af

Browse files
committed
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[].
1 parent 26da8fa commit 51cb8af

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/libpmemobj++/experimental/radix_tree.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@ radix_tree<Key, Value, BytesView>::internal_find(const K &k) const
17441744
while (n && !n.is_leaf()) {
17451745
if (path_length_equal(key.size(), n))
17461746
n = n->embedded_entry;
1747-
else if (n->byte > key.size())
1747+
else if (n->byte >= key.size())
17481748
return nullptr;
17491749
else
17501750
n = n->child[slice_index(key[n->byte], n->bit)];

0 commit comments

Comments
 (0)