mirror of
https://github.com/lz4/lz4.git
synced 2024-12-18 06:04:07 +08:00
fixed minor warning in fuzzer.c
added a few more comments and assert()
This commit is contained in:
parent
63fc6fbf7e
commit
b87a8e9e62
14
lib/lz4.c
14
lib/lz4.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
LZ4 - Fast LZ compression algorithm
|
||||
Copyright (C) 2011-2017, Yann Collet.
|
||||
Copyright (C) 2011-present, Yann Collet.
|
||||
|
||||
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
@ -1405,9 +1405,9 @@ LZ4_decompress_generic(
|
||||
int srcSize,
|
||||
int outputSize, /* If endOnInput==endOnInputSize, this value is `dstCapacity` */
|
||||
|
||||
endCondition_directive endOnInput, /* endOnOutputSize, endOnInputSize */
|
||||
earlyEnd_directive partialDecoding, /* full, partial */
|
||||
int dict, /* noDict, withPrefix64k, usingExtDict */
|
||||
endCondition_directive endOnInput, /* endOnOutputSize, endOnInputSize */
|
||||
earlyEnd_directive partialDecoding, /* full, partial */
|
||||
dict_directive dict, /* noDict, withPrefix64k, usingExtDict */
|
||||
const BYTE* const lowPrefix, /* always <= dst, == dst when no prefix */
|
||||
const BYTE* const dictStart, /* only if dict==usingExtDict */
|
||||
const size_t dictSize /* note : = 0 if noDict */
|
||||
@ -1434,6 +1434,7 @@ LZ4_decompress_generic(
|
||||
DEBUGLOG(5, "LZ4_decompress_generic (srcSize:%i, dstSize:%i)", srcSize, outputSize);
|
||||
|
||||
/* Special cases */
|
||||
assert(lowPrefix <= op);
|
||||
assert(src != NULL);
|
||||
if ((endOnInput) && (unlikely(outputSize==0))) return ((srcSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */
|
||||
if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0 ? 1 : -1);
|
||||
@ -1504,6 +1505,7 @@ LZ4_decompress_generic(
|
||||
|
||||
/* copy literals */
|
||||
cpy = op+length;
|
||||
LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
|
||||
if ( ((endOnInput) && ((cpy>oend-MFLIMIT) || (ip+length>iend-(2+1+LASTLITERALS))) )
|
||||
|| ((!endOnInput) && (cpy>oend-WILDCOPYLENGTH)) )
|
||||
{
|
||||
@ -1523,7 +1525,7 @@ LZ4_decompress_generic(
|
||||
}
|
||||
|
||||
} else {
|
||||
LZ4_wildCopy(op, ip, cpy);
|
||||
LZ4_wildCopy(op, ip, cpy); /* may overwrite up to WILDCOPYLENGTH beyond cpy */
|
||||
ip += length; op = cpy;
|
||||
}
|
||||
|
||||
@ -1584,7 +1586,7 @@ _copy_match:
|
||||
/* copy match within block */
|
||||
cpy = op + length;
|
||||
|
||||
/* specific : partial decode : does not respect end parsing restrictions */
|
||||
/* partialDecoding : may not respect endBlock parsing restrictions */
|
||||
assert(op<=oend);
|
||||
if (partialDecoding && (cpy > oend-12)) {
|
||||
size_t const mlen = MIN(length, (size_t)(oend-op));
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* LZ4 - Fast LZ compression algorithm
|
||||
* Header File
|
||||
* Copyright (C) 2011-2017, Yann Collet.
|
||||
* Copyright (C) 2011-present, Yann Collet.
|
||||
|
||||
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
@ -46,7 +46,7 @@ extern "C" {
|
||||
/**
|
||||
Introduction
|
||||
|
||||
LZ4 is lossless compression algorithm, providing compression speed at 400 MB/s per core,
|
||||
LZ4 is lossless compression algorithm, providing compression speed at 500 MB/s per core,
|
||||
scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
|
||||
multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
|
||||
|
||||
@ -62,8 +62,8 @@ extern "C" {
|
||||
|
||||
An additional format, called LZ4 frame specification (doc/lz4_Frame_format.md),
|
||||
take care of encoding standard metadata alongside LZ4-compressed blocks.
|
||||
If your application requires interoperability, it's recommended to use it.
|
||||
A library is provided to take care of it, see lz4frame.h.
|
||||
Frame format is required for interoperability.
|
||||
It is delivered through a companion API, declared in lz4frame.h.
|
||||
*/
|
||||
|
||||
/*^***************************************************************
|
||||
|
@ -583,7 +583,6 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
|
||||
{ size_t const missingBytes = FUZ_rand(&randState) % blockSize;
|
||||
int const targetSize = (int)(blockSize - missingBytes);
|
||||
char const sentinel = decodedBuffer[targetSize] = block[targetSize] ^ 0x5A;
|
||||
assert(decodedBuffer[targetSize] == sentinel);
|
||||
int const decResult = LZ4_decompress_safe_partial(compressedBuffer, decodedBuffer, compressedSize, targetSize, blockSize);
|
||||
FUZ_CHECKTEST(decResult<0, "LZ4_decompress_safe_partial failed despite valid input data (error:%i)", decResult);
|
||||
FUZ_CHECKTEST(decResult != targetSize, "LZ4_decompress_safe_partial did not regenerated required amount of data (%i < %i <= %i)", decResult, targetSize, blockSize);
|
||||
|
Loading…
Reference in New Issue
Block a user