From 79981d2ad2c356116578c509176b817ac7ab88d9 Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Wed, 13 Dec 2023 11:16:12 +0100 Subject: [PATCH] Bugfix Due to wrong cast of void pointer, pointers to potential buckets were compared and eventually sorted in wrong order, thus assigning wrong buckets to trie nodes. This caused some trie nodes to stay in trie even though they should have been removed. Consequently, trie contained superfluos prefixes after the algorithm finished. Since pointers were never dereferenced, only compared by their numeric values in the comparator function, program did not crash (even though pointers could be NULL because of the incorrect cast to double pointer and single dereference). --- proto/aggregator/aggregator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index 40585e0e..ea98a377 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -234,8 +234,8 @@ aggregator_bucket_compare(const void *a, const void *b) if (b == NULL) return 1; - const struct aggregator_bucket *fst = *(struct aggregator_bucket **)a; - const struct aggregator_bucket *snd = *(struct aggregator_bucket **)b; + const struct aggregator_bucket *fst = (struct aggregator_bucket *)a; + const struct aggregator_bucket *snd = (struct aggregator_bucket *)b; /* There is linear ordering on pointers */ if (fst < snd)