fix another ubsan warning in lz4hc because ubsan complains even about intermediate pointer arithmetic results (in a simple linear formula with 3 factors for example). use parenthesis to make sure calculations go directly from one valid memory address to another valid memory address value.
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index cf77a0a..33b5de4 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c
@@ -366,7 +366,7 @@ if ( (repeat == rep_confirmed) && (matchCandidateIdx >= lowestMatchIndex) && LZ4HC_protectDictEnd(prefixIdx, matchCandidateIdx) ) { const int extDict = matchCandidateIdx < prefixIdx; - const BYTE* const matchPtr = (extDict ? dictStart - dictIdx : prefixPtr - prefixIdx) + matchCandidateIdx; + const BYTE* const matchPtr = extDict ? dictStart + (matchCandidateIdx - dictIdx) : prefixPtr + (matchCandidateIdx - prefixIdx); if (LZ4_read32(matchPtr) == pattern) { /* good candidate */ const BYTE* const iLimit = extDict ? dictEnd : iHighLimit; size_t forwardPatternLength = LZ4HC_countPattern(matchPtr+sizeof(pattern), iLimit, pattern) + sizeof(pattern);