diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2022-10-01 01:06:53 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2022-10-01 01:06:53 (GMT) |
commit | 68848ec601b96c0d9f86e91585309b2738d2c48c (patch) | |
tree | ebfbd4084d308347e98f3c77e03039edce40d610 /lib | |
parent | a3d1762092c624732eb93a1e28c1abdb7566fb87 (diff) | |
download | lz4-md_off.zip lz4-md_off.tar.gz lz4-md_off.tar.bz2 |
fix another ubsan warning in lz4hcmd_off
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4hc.c | 2 |
1 files changed, 1 insertions, 1 deletions
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 @@ LZ4HC_InsertAndGetWiderMatch ( 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); |