launchdarkly / cpp-sdks

C++ Client/Server SDKs
Other
5 stars 2 forks source link

fix: Summarizer::VariationKey operator< was unsound #412

Closed cwaldren-ld closed 1 month ago

cwaldren-ld commented 2 months ago

This is a soundness bug that was detected by MSVC in debug configuration.

The Summarizer::VariationKey has == and < operators.

In the case of <, the comparison wasn't properly handling the case where this->variation was greater than the parameter. In that case, it would fall back to comparing this->version which is incorrect (should only happen if the variations are equal.)

This could have affected the JSON serialization of the summary counters, mainly the order in which the array was serialized. I'm wondering if it could also caused bugs in actual counts. std::map uses the < operator to determine key equality.