Merge pull request #753 from Hitatm/fix_LZ4_DISTANCE_MAX

bugfix: correctly control the offset < LZ4_DISTANCE_MAX,when change t…
This commit is contained in:
Yann Collet 2019-07-15 09:08:11 -07:00 committed by GitHub
commit a23541463d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -228,7 +228,7 @@ LZ4HC_InsertAndGetWiderMatch (
const U32 dictLimit = hc4->dictLimit; const U32 dictLimit = hc4->dictLimit;
const BYTE* const lowPrefixPtr = base + dictLimit; const BYTE* const lowPrefixPtr = base + dictLimit;
const U32 ipIndex = (U32)(ip - base); const U32 ipIndex = (U32)(ip - base);
const U32 lowestMatchIndex = (hc4->lowLimit + 64 KB > ipIndex) ? hc4->lowLimit : ipIndex - LZ4_DISTANCE_MAX; const U32 lowestMatchIndex = (hc4->lowLimit + (LZ4_DISTANCE_MAX + 1) > ipIndex) ? hc4->lowLimit : ipIndex - LZ4_DISTANCE_MAX;
const BYTE* const dictBase = hc4->dictBase; const BYTE* const dictBase = hc4->dictBase;
int const lookBackLength = (int)(ip-iLowLimit); int const lookBackLength = (int)(ip-iLowLimit);
int nbAttempts = maxNbAttempts; int nbAttempts = maxNbAttempts;