From 87968517f926b55c2af3cf39e9692b368c566103 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 4 Oct 2017 15:24:08 -0700 Subject: fixed decoding block checksum in lz4frame --- lib/lz4frame.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/lz4frame.c b/lib/lz4frame.c index 4df404c..3adbdd9 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -1268,12 +1268,11 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx, if (dctx->frameInfo.contentChecksumFlag) XXH32_reset(&(dctx->xxh), 0); /* internal buffers allocation */ { size_t const bufferNeeded = dctx->maxBlockSize - + ((dctx->frameInfo.blockMode==LZ4F_blockLinked) * 128 KB) - + 4 /* block checksum */; + + ((dctx->frameInfo.blockMode==LZ4F_blockLinked) * 128 KB); if (bufferNeeded > dctx->maxBufferSize) { /* tmp buffers too small */ dctx->maxBufferSize = 0; /* ensure allocation will be re-attempted on next entry*/ FREEMEM(dctx->tmpIn); - dctx->tmpIn = (BYTE*)ALLOCATOR(dctx->maxBlockSize); + dctx->tmpIn = (BYTE*)ALLOCATOR(dctx->maxBlockSize + 4 /* block checksum */); if (dctx->tmpIn == NULL) return err0r(LZ4F_ERROR_allocation_failed); FREEMEM(dctx->tmpOutBuffer); @@ -1407,7 +1406,7 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx, dctx->dStage = dstage_getBlockHeader; /* new block */ break; - case dstage_getCBlock: /* entry from dstage_decodeCBlockSize */ + case dstage_getCBlock: if ((size_t)(srcEnd-srcPtr) < dctx->tmpInTarget) { dctx->tmpInSize = 0; dctx->dStage = dstage_storeCBlock; -- cgit v0.12