diff --git a/lz4frame.c b/lz4frame.c index 390af0e..7bc2319 100644 --- a/lz4frame.c +++ b/lz4frame.c @@ -775,15 +775,6 @@ static void LZ4F_saveDict(LZ4F_dctx_internal_t* dctxPtr, const BYTE* decoded, si static void LZ4F_pointDict(LZ4F_dctx_internal_t* dctxPtr, const BYTE* decoded, size_t decodedSize) { - /* large decoded block */ - if (decodedSize >= (64 KB - 1)) - { - dctxPtr->dict = (BYTE*)decoded; - dctxPtr->dictSize = decodedSize; - dctxPtr->tmpOut = dctxPtr->tmpOutBuffer + 64 KB; - return; - } - /* decoded block in the continuity of dictionary */ if (dctxPtr->dict + dctxPtr->dictSize == decoded) { @@ -800,6 +791,15 @@ static void LZ4F_pointDict(LZ4F_dctx_internal_t* dctxPtr, const BYTE* decoded, s return; } + /* large decoded block */ + if (decodedSize >= (64 KB - 1)) + { + dctxPtr->dict = (BYTE*)decoded; + dctxPtr->dictSize = decodedSize; + dctxPtr->tmpOut = dctxPtr->tmpOutBuffer + 64 KB; + return; + } + /* small block, and not contiguous : let's save that */ LZ4F_saveDict(dctxPtr, decoded, decodedSize); } @@ -953,6 +953,11 @@ size_t LZ4F_decompress(LZ4F_decompressionContext_t decompressionContext, break; } dctxPtr->dStage = dstage_getCBlock; + if (dstPtr==dstEnd) + { + nextSrcSizeHint = nextCBlockSize + 4; + doAnotherStage = 0; + } break; } diff --git a/programs/frametest.c b/programs/frametest.c index 8be7752..ba24fe1 100644 --- a/programs/frametest.c +++ b/programs/frametest.c @@ -466,12 +466,11 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi while (ip < iend) { unsigned nbBitsI = (FUZ_rand(&randState) % (maxBits-1)) + 1; - unsigned nbBitsO = (FUZ_rand(&randState) % (maxBits-1)) + 1; + unsigned nbBitsO = (FUZ_rand(&randState) % (maxBits)) + 1; size_t iSize = (FUZ_rand(&randState) & ((1< (size_t)(iend-ip)) iSize = iend-ip; if (oSize > (size_t)(oend-op)) oSize = oend-op; - oSize = oend-op; result = LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, NULL); if (result == (size_t)-ERROR_checksum_invalid) locateBuffDiff((BYTE*)srcBuffer+srcStart, decodedBuffer, srcSize); CHECK(LZ4F_isError(result), "Decompression failed (error %i)", (int)result);