Skip to contentSkip to conversation

master - radix-tree: Fix bug in remove_prefix()

PATCH Joe Thornber 1 participant 1 message Aug 20, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8b05f1f230517aa42878aa160d94383ed0534c64
Commit:        8b05f1f230517aa42878aa160d94383ed0534c64
Parent:        54668feaabead997cdf099c970999af667bcf274
Author:        Joe Thornber <[email protected]>
AuthorDate:    Mon Aug 20 15:23:40 2018 +0100
Committer:     Joe Thornber <[email protected]>
CommitterDate: Mon Aug 20 15:23:40 2018 +0100

radix-tree: Fix bug in remove_prefix()

Accidental decrement of the nr entries when a n256 didn't have the entry in the first place.

---
 base/data-struct/radix-tree.c |    3 +
 test/unit/radix_tree_t.c      |  116 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+), 0 deletions(-)
base/data-struct/radix-tree.c +3 -0
index 1d24dad..1eef1f8 100644
@@ -907,6 +907,9 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *
 
 	case NODE256:
 		n256 = root->value.ptr;
+		if (n256->values[*kb].type == UNSET)
+			return true;  // No entries
+
 		r = _remove_subtree(rt, n256->values + (*kb), kb + 1, ke, count);
 		if (r && n256->values[*kb].type == UNSET) {
 			n256->nr_entries--;
test/unit/radix_tree_t.c +116 -0

128 lines not on this page · raw message