From: W. Felix Handte Date: Tue, 15 May 2018 19:45:37 +0000 (-0400) Subject: Avoid Undefined Behavior in Match Ptr Calculation X-Git-Tag: v1.3.5~3^2~44^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c92223468acca6e5a7082e4e09b1f6870df7aa4;p=thirdparty%2Fzstd.git Avoid Undefined Behavior in Match Ptr Calculation --- diff --git a/lib/compress/zstd_fast.c b/lib/compress/zstd_fast.c index 09b1a8ec3..b21bc7683 100644 --- a/lib/compress/zstd_fast.c +++ b/lib/compress/zstd_fast.c @@ -99,10 +99,10 @@ size_t ZSTD_compressBlock_fast_generic( U32 const matchIndex = hashTable[h]; const BYTE* match = base + matchIndex; const U32 repIndex = current + 1 - offset_1; - const BYTE* repBase = (dictMode == ZSTD_dictMatchState + const BYTE* repMatch = (dictMode == ZSTD_dictMatchState && repIndex < prefixLowestIndex) ? - dictBase - dictIndexDelta : base; - const BYTE* repMatch = repBase + repIndex; + dictBase + (repIndex - dictIndexDelta) : + base + repIndex; hashTable[h] = current; /* update hash table */ if (dictMode == ZSTD_dictMatchState