libpmemobj-cpp/radix-fix.patch
Petr Šabata 06140b9e8d RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/libpmemobj-cpp#8a5a0d9be0d8924be9ec7e1aa17ef9ea7bd32730
2020-10-15 16:58:01 +02:00

30 lines
1.2 KiB
Diff

From 51cb8afb804db8e71007fb238dab9f9ff0f09ec8 Mon Sep 17 00:00:00 2001
From: Igor Chorążewicz <igor.chorazewicz@intel.com>
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<Key, Value, BytesView>::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