fix incorrect counting
after truncation of last sequence
This commit is contained in:
parent
e7fe105ac6
commit
a13c79d56d
@ -481,7 +481,7 @@ LZ4_FORCE_INLINE int LZ4HC_encodeSequence (
|
|||||||
U32 const cost = 1 + llAdd + ll + 2 + mlAdd;
|
U32 const cost = 1 + llAdd + ll + 2 + mlAdd;
|
||||||
if (start==NULL) start = *anchor; /* only works for single segment */
|
if (start==NULL) start = *anchor; /* only works for single segment */
|
||||||
/* g_debuglog_enable = (pos >= 2228) & (pos <= 2262); */
|
/* g_debuglog_enable = (pos >= 2228) & (pos <= 2262); */
|
||||||
DEBUGLOG(6, "pos:%7u -- literals:%3u, match:%4i, offset:%5u, cost:%3u + %u",
|
DEBUGLOG(6, "pos:%7u -- literals:%4u, match:%4i, offset:%5u, cost:%4u + %5u",
|
||||||
pos,
|
pos,
|
||||||
(U32)(*ip - *anchor), matchLength, (U32)(*ip-match),
|
(U32)(*ip - *anchor), matchLength, (U32)(*ip-match),
|
||||||
cost, totalCost);
|
cost, totalCost);
|
||||||
@ -726,7 +726,7 @@ _last_literals:
|
|||||||
lastRunSize -= llAdd;
|
lastRunSize -= llAdd;
|
||||||
}
|
}
|
||||||
DEBUGLOG(6, "Final literal run : %i literals", (int)lastRunSize);
|
DEBUGLOG(6, "Final literal run : %i literals", (int)lastRunSize);
|
||||||
ip = ip + lastRunSize; /* can be != iend if limit==fillOutput */
|
ip = anchor + lastRunSize; /* can be != iend if limit==fillOutput */
|
||||||
|
|
||||||
if (lastRunSize >= RUN_MASK) {
|
if (lastRunSize >= RUN_MASK) {
|
||||||
size_t accumulator = lastRunSize - RUN_MASK;
|
size_t accumulator = lastRunSize - RUN_MASK;
|
||||||
@ -751,6 +751,7 @@ _dest_overflow:
|
|||||||
size_t const ll_addbytes = (ll + 240) / 255;
|
size_t const ll_addbytes = (ll + 240) / 255;
|
||||||
size_t const ll_totalCost = 1 + ll_addbytes + ll;
|
size_t const ll_totalCost = 1 + ll_addbytes + ll;
|
||||||
BYTE* const maxLitPos = oend - 3; /* 2 for offset, 1 for token */
|
BYTE* const maxLitPos = oend - 3; /* 2 for offset, 1 for token */
|
||||||
|
DEBUGLOG(6, "Last sequence overflowing");
|
||||||
op = optr; /* restore correct out pointer */
|
op = optr; /* restore correct out pointer */
|
||||||
if (op + ll_totalCost <= maxLitPos) {
|
if (op + ll_totalCost <= maxLitPos) {
|
||||||
/* ll validated; now how many matches ? */
|
/* ll validated; now how many matches ? */
|
||||||
|
@ -447,7 +447,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
|
|||||||
decodedBuffer[srcSize] = canary;
|
decodedBuffer[srcSize] = canary;
|
||||||
{ int const dSize = LZ4_decompress_safe(compressedBuffer, decodedBuffer, cSize, srcSize);
|
{ int const dSize = LZ4_decompress_safe(compressedBuffer, decodedBuffer, cSize, srcSize);
|
||||||
FUZ_CHECKTEST(dSize<0, "LZ4_decompress_safe() failed on data compressed by LZ4_compressHC_destSize");
|
FUZ_CHECKTEST(dSize<0, "LZ4_decompress_safe() failed on data compressed by LZ4_compressHC_destSize");
|
||||||
FUZ_CHECKTEST(dSize!=srcSize, "LZ4_decompress_safe() failed : did not fully decompressed data");
|
FUZ_CHECKTEST(dSize!=srcSize, "LZ4_decompress_safe() failed : decompressed %i bytes, was supposed to decompress %i bytes", dSize, srcSize);
|
||||||
}
|
}
|
||||||
FUZ_CHECKTEST(decodedBuffer[srcSize] != canary, "LZ4_decompress_safe() overwrite dst buffer !");
|
FUZ_CHECKTEST(decodedBuffer[srcSize] != canary, "LZ4_decompress_safe() overwrite dst buffer !");
|
||||||
{ U32 const crcDec = XXH32(decodedBuffer, (size_t)srcSize, 0);
|
{ U32 const crcDec = XXH32(decodedBuffer, (size_t)srcSize, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user