Skip to content

Commit

Permalink
[szs] MK8: Remove sneaky reliance on unsigned underflow for range che…
Browse files Browse the repository at this point in the history
…ck (from implicit conversion)
  • Loading branch information
riidefi committed Aug 24, 2024
1 parent c1a3bcc commit 78e45e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/szs/src/MK8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static inline bool search(Match& match, const s32 search_pos_immut,

// There are no deletions from the hash chains; the algorithm
// simply discards matches that are too old.
if (data_pos - search_pos > SEARCH_WINDOW_SIZE) {
if (search_pos > data_pos || data_pos > search_pos + SEARCH_WINDOW_SIZE) {
return false;
}

Expand Down Expand Up @@ -161,6 +161,8 @@ static inline bool search(Match& match, const s32 search_pos_immut,
}

search_pos = work.search_pos(search_pos);
// There are no deletions from the hash chains; the algorithm
// simply discards matches that are too old.
if (search_pos <= search_pos_min) {
break;
}
Expand Down

0 comments on commit 78e45e9

Please sign in to comment.