Refactor dictionary matchfinder index safety check (#4039)

This commit is contained in:
Federico Maresca
2024-05-29 12:35:24 -04:00
committed by GitHub
parent 0e2ceb2d50
commit 5e9a6c2fe4
5 changed files with 24 additions and 18 deletions
+7
View File
@@ -1315,6 +1315,13 @@ MEM_STATIC U32 ZSTD_getLowestPrefixIndex(const ZSTD_matchState_t* ms, U32 curr,
return matchLowest;
}
/* index_safety_check:
* intentional underflow : ensure repIndex isn't overlapping dict + prefix
* @return 1 if values are not overlapping,
* 0 otherwise */
MEM_STATIC int ZSTD_index_overlap_check(const U32 prefixLowestIndex, const U32 repIndex) {
return ((U32)((prefixLowestIndex-1) - repIndex) >= 3);
}
/* debug functions */