summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2020-07-08 16:12:25 (GMT)
committerGitHub <noreply@github.com>2020-07-08 16:12:25 (GMT)
commit6b12fde42a3156441a994153997018940c5d8142 (patch)
treee6eef71097e78ffc37ed53a4ca689b27018f9603
parent49b3ad4bd41311e92fc3a18eda571800bde5aa42 (diff)
parente68c7d38780ada518e6c43a09a2d92421ea8111b (diff)
downloadlz4-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.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 82ab490..2f7880a 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -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;