diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2020-07-08 16:12:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 16:12:25 (GMT) |
commit | 6b12fde42a3156441a994153997018940c5d8142 (patch) | |
tree | e6eef71097e78ffc37ed53a4ca689b27018f9603 | |
parent | 49b3ad4bd41311e92fc3a18eda571800bde5aa42 (diff) | |
parent | e68c7d38780ada518e6c43a09a2d92421ea8111b (diff) | |
download | lz4-6b12fde42a3156441a994153997018940c5d8142.zip lz4-6b12fde42a3156441a994153997018940c5d8142.tar.gz lz4-6b12fde42a3156441a994153997018940c5d8142.tar.bz2 |
Merge pull request #884 from vectorizedio/clang-ubsan
avoid computing 0 offsets from null pointers
-rw-r--r-- | lib/lz4.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -819,7 +819,7 @@ LZ4_FORCE_INLINE int LZ4_compress_generic( int const maybe_extMem = (dictDirective == usingExtDict) || (dictDirective == usingDictCtx); U32 const prefixIdxLimit = startIndex - dictSize; /* used when dictDirective == dictSmall */ - const BYTE* const dictEnd = dictionary + dictSize; + const BYTE* const dictEnd = dictionary ? dictionary + dictSize : dictionary; const BYTE* anchor = (const BYTE*) source; const BYTE* const iend = ip + inputSize; const BYTE* const mflimitPlusOne = iend - MFLIMIT + 1; @@ -827,7 +827,7 @@ LZ4_FORCE_INLINE int LZ4_compress_generic( /* the dictCtx currentOffset is indexed on the start of the dictionary, * while a dictionary in the current context precedes the currentOffset */ - const BYTE* dictBase = (dictDirective == usingDictCtx) ? + const BYTE* dictBase = !dictionary ? NULL : (dictDirective == usingDictCtx) ? dictionary + dictSize - dictCtx->currentOffset : dictionary + dictSize - startIndex; |