diff options
author | Yann Collet <cyan@fb.com> | 2020-11-09 07:26:19 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2020-11-09 07:26:19 (GMT) |
commit | 44b13db53201927814a21cd962ad5979745e2d17 (patch) | |
tree | 80efbddc428e41d7b2abcc5ad158cd812daceeff /lib | |
parent | 52646e8d7517b9b399d3e3719c65816afdc833ab (diff) | |
parent | 9cf3f106a8dea906ff4550f749112e9e89536678 (diff) | |
download | lz4-44b13db53201927814a21cd962ad5979745e2d17.zip lz4-44b13db53201927814a21cd962ad5979745e2d17.tar.gz lz4-44b13db53201927814a21cd962ad5979745e2d17.tar.bz2 |
Merge branch 'dev' into customMem
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4.c | 4 | ||||
-rw-r--r-- | lib/lz4hc.c | 7 |
2 files changed, 7 insertions, 4 deletions
@@ -1619,7 +1619,7 @@ int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream, * cost to copy the dictionary's tables into the active context, * so that the compression loop is only looking into one table. */ - LZ4_memcpy(streamPtr, streamPtr->dictCtx, sizeof(LZ4_stream_t)); + LZ4_memcpy(streamPtr, streamPtr->dictCtx, sizeof(*streamPtr)); result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingExtDict, noDictIssue, acceleration); } else { result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingDictCtx, noDictIssue, acceleration); @@ -1675,7 +1675,7 @@ int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize) if ((U32)dictSize > dict->dictSize) { dictSize = (int)dict->dictSize; } if (safeBuffer == NULL) assert(dictSize == 0); - if (safeBuffer != NULL) + if (dictSize > 0) memmove(safeBuffer, previousDictEnd - dictSize, dictSize); dict->dictionary = (const BYTE*)safeBuffer; diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 8320f33..8c6063f 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -1163,13 +1163,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; } |