Merge pull request #443 from terrelln/440

[lz4f] Skip memcpy() on empty dictionary
This commit is contained in:
Yann Collet 2018-01-10 19:06:21 +01:00 committed by GitHub
commit 58199f1311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1631,7 +1631,8 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
if (dctx->tmpOutSize > 64 KB) copySize = 0;
if (copySize > preserveSize) copySize = preserveSize;
memcpy(dctx->tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
if (copySize > 0)
memcpy(dctx->tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
dctx->dict = dctx->tmpOutBuffer;
dctx->dictSize = preserveSize + dctx->tmpOutStart;
@ -1639,7 +1640,8 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
const BYTE* const oldDictEnd = dctx->dict + dctx->dictSize;
size_t const newDictSize = MIN(dctx->dictSize, 64 KB);
memcpy(dctx->tmpOutBuffer, oldDictEnd - newDictSize, newDictSize);
if (newDictSize > 0)
memcpy(dctx->tmpOutBuffer, oldDictEnd - newDictSize, newDictSize);
dctx->dict = dctx->tmpOutBuffer;
dctx->dictSize = newDictSize;