From 4faf912ab1acc883ced56ceefa5bd347e2bfc38b Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 16 Jul 2024 15:19:54 +0200 Subject: [PATCH] Correctly locate part range in which read data. As describe in https://en.cppreference.com/w/cpp/algorithm/equal_range, equal_range is undefined behavior if `bool(comp(elem, value))` does not imply `!bool(comp(value, elem))`. This is the case here for exemple with : - value = Range{min:10, max:10} - elem = Range{min:10, max:11} - comp(value, elem) => value.min < elem.min && value.max <= elem.min => 10 < 10 && 10 <= 10 => false && true => false - comp(elem, value) => elem.min < value.min && elem.max <= value.min => 10 < 10 && 11 <= 10 => false && false => false `lower_bound` and `upper_bound` don't have such requirement on `comp`. --- src/file_compound.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/file_compound.h b/src/file_compound.h index f50d672b..ab9a21b0 100644 --- a/src/file_compound.h +++ b/src/file_compound.h @@ -87,20 +87,16 @@ class LIBZIM_PRIVATE_API FileCompound : private std::map