diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2020-11-09 02:08:43 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2020-11-09 02:08:43 (GMT) |
commit | 2a2b10f19242aedc8598b74bcb4614d03485c3c0 (patch) | |
tree | ea4c5f4fbe2d76d1f16ad05d4396310b23d1cd83 /lib/lz4hc.c | |
parent | e251a840253c5564364bf5c8c662a6fe623dc3e9 (diff) | |
download | lz4-2a2b10f19242aedc8598b74bcb4614d03485c3c0.zip lz4-2a2b10f19242aedc8598b74bcb4614d03485c3c0.tar.gz lz4-2a2b10f19242aedc8598b74bcb4614d03485c3c0.tar.bz2 |
fixed remaining ubsan warnings
Diffstat (limited to 'lib/lz4hc.c')
-rw-r--r-- | lib/lz4hc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 8875f1a..286ff68 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -1164,13 +1164,16 @@ int LZ4_saveDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, char* safeBuffer, int dictS if (dictSize > 64 KB) dictSize = 64 KB; if (dictSize < 4) dictSize = 0; if (dictSize > prefixSize) dictSize = prefixSize; - memmove(safeBuffer, streamPtr->end - dictSize, dictSize); + if (safeBuffer == NULL) assert(dictSize == 0); + if (dictSize > 0) + memmove(safeBuffer, streamPtr->end - dictSize, dictSize); { U32 const endIndex = (U32)(streamPtr->end - streamPtr->base); streamPtr->end = (const BYTE*)safeBuffer + dictSize; streamPtr->base = streamPtr->end - endIndex; streamPtr->dictLimit = endIndex - (U32)dictSize; streamPtr->lowLimit = endIndex - (U32)dictSize; - if (streamPtr->nextToUpdate < streamPtr->dictLimit) streamPtr->nextToUpdate = streamPtr->dictLimit; + if (streamPtr->nextToUpdate < streamPtr->dictLimit) + streamPtr->nextToUpdate = streamPtr->dictLimit; } return dictSize; } |