diff --git a/source/szs/src/MK8.hpp b/source/szs/src/MK8.hpp index 78c7175c..905b3265 100644 --- a/source/szs/src/MK8.hpp +++ b/source/szs/src/MK8.hpp @@ -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; } @@ -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; }