summaryrefslogtreecommitdiffstats
path: root/lib/lz4frame.c
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2018-01-10 18:06:21 (GMT)
committerGitHub <noreply@github.com>2018-01-10 18:06:21 (GMT)
commit58199f131190af0b7542a9d662387f32ccb78ff3 (patch)
treec2bb5af066a658749ed5c5f431c672e581e93e77 /lib/lz4frame.c
parenta605d7ea54028395e4d4c87793e545951c20cd3e (diff)
parentc2dd686e96c7c4ff6a84bd43b68d3c28369e1f95 (diff)
downloadlz4-58199f131190af0b7542a9d662387f32ccb78ff3.zip
lz4-58199f131190af0b7542a9d662387f32ccb78ff3.tar.gz
lz4-58199f131190af0b7542a9d662387f32ccb78ff3.tar.bz2
Merge pull request #443 from terrelln/440
[lz4f] Skip memcpy() on empty dictionary
Diffstat (limited to 'lib/lz4frame.c')
-rw-r--r--lib/lz4frame.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index ebd1089..488ab75 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -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;