Skip to content

Commit 179c89f

Browse files
committed
fix overflow on 32 bit systems
1 parent 76befcc commit 179c89f

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## Changelog
22

3-
## [3.1.0] - 2024-10-24
3+
## [3.1.1] - 2024-10-24
4+
### Fixed
5+
- Fixed incorrect score calculation for SIMD implementations of Levenshtein and OSA on 32 bit systems
6+
7+
## [3.1.0] - 024-10-24
48
### Changed
59
- split `editops_apply`/`opcodes_apply` into `*_apply_str` and `*_apply_vec`. This avoids the instantiation of
610
std::basic_string for unsupported types.

extras/rapidfuzz_amalgamated.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
22
// SPDX-License-Identifier: MIT
33
// RapidFuzz v1.0.2
4-
// Generated: 2024-10-24 12:06:59.588890
4+
// Generated: 2024-10-24 14:07:33.184436
55
// ----------------------------------------------------------
66
// This file is an amalgamation of multiple different files.
77
// You probably shouldn't edit it directly.
@@ -7027,7 +7027,7 @@ void levenshtein_hyrroe2003_simd(Range<size_t*> scores, const detail::BlockPatte
70277027
}
70287028
/* calculate score under consideration of wraparounds in parallel counter */
70297029
else {
7030-
if constexpr (!std::is_same_v<VecType, uint64_t>) {
7030+
if constexpr (std::numeric_limits<VecType>::max() < std::numeric_limits<size_t>::max()) {
70317031
size_t min_dist = abs_diff(s1_lengths[result_index], s2.size());
70327032
size_t wraparound_score = static_cast<size_t>(std::numeric_limits<VecType>::max()) + 1;
70337033

@@ -8512,7 +8512,7 @@ void osa_hyrroe2003_simd(Range<size_t*> scores, const detail::BlockPatternMatchV
85128512
}
85138513
/* calculate score under consideration of wraparounds in parallel counter */
85148514
else {
8515-
if constexpr (!std::is_same_v<VecType, uint64_t>) {
8515+
if constexpr (std::numeric_limits<VecType>::max() < std::numeric_limits<size_t>::max()) {
85168516
size_t min_dist = abs_diff(s1_lengths[result_index], s2.size());
85178517
size_t wraparound_score = static_cast<size_t>(std::numeric_limits<VecType>::max()) + 1;
85188518

rapidfuzz/distance/Levenshtein_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ void levenshtein_hyrroe2003_simd(Range<size_t*> scores, const detail::BlockPatte
363363
}
364364
/* calculate score under consideration of wraparounds in parallel counter */
365365
else {
366-
if constexpr (!std::is_same_v<VecType, uint64_t>) {
366+
if constexpr (std::numeric_limits<VecType>::max() < std::numeric_limits<size_t>::max()) {
367367
size_t min_dist = abs_diff(s1_lengths[result_index], s2.size());
368368
size_t wraparound_score = static_cast<size_t>(std::numeric_limits<VecType>::max()) + 1;
369369

rapidfuzz/distance/OSA_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void osa_hyrroe2003_simd(Range<size_t*> scores, const detail::BlockPatternMatchV
151151
}
152152
/* calculate score under consideration of wraparounds in parallel counter */
153153
else {
154-
if constexpr (!std::is_same_v<VecType, uint64_t>) {
154+
if constexpr (std::numeric_limits<VecType>::max() < std::numeric_limits<size_t>::max()) {
155155
size_t min_dist = abs_diff(s1_lengths[result_index], s2.size());
156156
size_t wraparound_score = static_cast<size_t>(std::numeric_limits<VecType>::max()) + 1;
157157

0 commit comments

Comments
 (0)