mirror of
https://github.com/facebook/zstd.git
synced 2025-08-05 19:15:58 +03:00
fixed asan warning
This commit is contained in:
@@ -213,7 +213,7 @@ static size_t ZBUFF_compressContinue_generic(ZBUFF_CCtx* zbc,
|
|||||||
/* prepare next block */
|
/* prepare next block */
|
||||||
zbc->inBuffTarget = zbc->inBuffPos + zbc->blockSize;
|
zbc->inBuffTarget = zbc->inBuffPos + zbc->blockSize;
|
||||||
if (zbc->inBuffTarget > zbc->inBuffSize)
|
if (zbc->inBuffTarget > zbc->inBuffSize)
|
||||||
{ zbc->inBuffPos = 0; zbc->inBuffTarget = zbc->blockSize; }
|
{ zbc->inBuffPos = 0; zbc->inBuffTarget = zbc->blockSize; } /* note : inBuffSize >= blockSize */
|
||||||
zbc->inToCompress = zbc->inBuffPos;
|
zbc->inToCompress = zbc->inBuffPos;
|
||||||
if (cDst == op) { op += cSize; break; } /* no need to flush */
|
if (cDst == op) { op += cSize; break; } /* no need to flush */
|
||||||
zbc->outBuffContentSize = cSize;
|
zbc->outBuffContentSize = cSize;
|
||||||
|
@@ -748,7 +748,7 @@ size_t ZSTD_compressBlock_fast_generic(ZSTD_CCtx* zc,
|
|||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
ZSTD_resetSeqStore(seqStorePtr);
|
ZSTD_resetSeqStore(seqStorePtr);
|
||||||
if (ip == base)
|
if (ip < base+4)
|
||||||
{
|
{
|
||||||
hashTable[ZSTD_hashPtr(base+1, hBits, mls)] = 1;
|
hashTable[ZSTD_hashPtr(base+1, hBits, mls)] = 1;
|
||||||
hashTable[ZSTD_hashPtr(base+2, hBits, mls)] = 2;
|
hashTable[ZSTD_hashPtr(base+2, hBits, mls)] = 2;
|
||||||
@@ -787,14 +787,14 @@ size_t ZSTD_compressBlock_fast_generic(ZSTD_CCtx* zc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* match found */
|
/* match found */
|
||||||
ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset, mlCode);
|
ZSTD_storeSeq(seqStorePtr, ip-anchor, anchor, offset, mlCode);
|
||||||
ip += mlCode + MINMATCH;
|
ip += mlCode + MINMATCH;
|
||||||
anchor = ip;
|
anchor = ip;
|
||||||
|
|
||||||
if (ip <= ilimit)
|
if (ip <= ilimit)
|
||||||
{
|
{
|
||||||
/* Fill Table */
|
/* Fill Table */
|
||||||
hashTable[ZSTD_hashPtr(ip-(mlCode+MINMATCH)+2, hBits, mls)] = (U32)(ip-(mlCode+MINMATCH)+2-base); /* here because ip-(mlCode+MINMATCH)+2 could be > iend-8 without ip <= ilimit check*/
|
hashTable[ZSTD_hashPtr(ip-(mlCode+MINMATCH)+2, hBits, mls)] = (U32)(ip-(mlCode+MINMATCH)+2-base); /* here because ip-(mlCode+MINMATCH)+2 could be > iend-8 without ip <= ilimit check*/
|
||||||
hashTable[ZSTD_hashPtr(ip-2, hBits, mls)] = (U32)(ip-2-base);
|
hashTable[ZSTD_hashPtr(ip-2, hBits, mls)] = (U32)(ip-2-base);
|
||||||
/* check immediate repcode */
|
/* check immediate repcode */
|
||||||
while ( (ip <= ilimit)
|
while ( (ip <= ilimit)
|
||||||
@@ -887,7 +887,7 @@ size_t ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx,
|
|||||||
const size_t h = ZSTD_hashPtr(ip, hBits, mls);
|
const size_t h = ZSTD_hashPtr(ip, hBits, mls);
|
||||||
const U32 matchIndex = hashTable[h];
|
const U32 matchIndex = hashTable[h];
|
||||||
const BYTE* matchBase = matchIndex < dictLimit ? dictBase : base;
|
const BYTE* matchBase = matchIndex < dictLimit ? dictBase : base;
|
||||||
const BYTE* match = matchBase + matchIndex;
|
const BYTE* match = matchBase + matchIndex;
|
||||||
const U32 current = (U32)(ip-base);
|
const U32 current = (U32)(ip-base);
|
||||||
const U32 repIndex = current + 1 - offset_1;
|
const U32 repIndex = current + 1 - offset_1;
|
||||||
const BYTE* repBase = repIndex < dictLimit ? dictBase : base;
|
const BYTE* repBase = repIndex < dictLimit ? dictBase : base;
|
||||||
@@ -927,7 +927,7 @@ size_t ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx,
|
|||||||
|
|
||||||
if (ip <= ilimit)
|
if (ip <= ilimit)
|
||||||
{
|
{
|
||||||
/* Fill Table */
|
/* Fill Table */
|
||||||
hashTable[ZSTD_hashPtr(base+current+2, hBits, mls)] = current+2;
|
hashTable[ZSTD_hashPtr(base+current+2, hBits, mls)] = current+2;
|
||||||
hashTable[ZSTD_hashPtr(ip-2, hBits, mls)] = (U32)(ip-2-base);
|
hashTable[ZSTD_hashPtr(ip-2, hBits, mls)] = (U32)(ip-2-base);
|
||||||
/* check immediate repcode */
|
/* check immediate repcode */
|
||||||
@@ -990,7 +990,7 @@ size_t ZSTD_compressBlock_fast_extDict(ZSTD_CCtx* ctx,
|
|||||||
* Binary Tree search
|
* Binary Tree search
|
||||||
***************************************/
|
***************************************/
|
||||||
/** ZSTD_insertBt1 : add one or multiple positions to tree
|
/** ZSTD_insertBt1 : add one or multiple positions to tree
|
||||||
* @ip : assumed <= iend-8
|
* @ip : assumed <= iend-8
|
||||||
* @return : nb of positions added */
|
* @return : nb of positions added */
|
||||||
static U32 ZSTD_insertBt1(ZSTD_CCtx* zc, const BYTE* const ip, const U32 mls, const BYTE* const iend, U32 nbCompares)
|
static U32 ZSTD_insertBt1(ZSTD_CCtx* zc, const BYTE* const ip, const U32 mls, const BYTE* const iend, U32 nbCompares)
|
||||||
{
|
{
|
||||||
@@ -1173,7 +1173,7 @@ FORCE_INLINE size_t ZSTD_BtFindBestMatch_selectMLS (
|
|||||||
|
|
||||||
|
|
||||||
/** ZSTD_insertBt1_extDict : add one or multiple positions to tree
|
/** ZSTD_insertBt1_extDict : add one or multiple positions to tree
|
||||||
* @ip : assumed <= iend-8
|
* @ip : assumed <= iend-8
|
||||||
* @return : nb of positions added */
|
* @return : nb of positions added */
|
||||||
static U32 ZSTD_insertBt1_extDict(ZSTD_CCtx* zc, const BYTE* const ip, const U32 mls, const BYTE* const iend, U32 nbCompares)
|
static U32 ZSTD_insertBt1_extDict(ZSTD_CCtx* zc, const BYTE* const ip, const U32 mls, const BYTE* const iend, U32 nbCompares)
|
||||||
{
|
{
|
||||||
@@ -1389,7 +1389,7 @@ FORCE_INLINE size_t ZSTD_BtFindBestMatch_selectMLS_extDict (
|
|||||||
|
|
||||||
#define NEXT_IN_CHAIN(d, mask) chainTable[(d) & mask]
|
#define NEXT_IN_CHAIN(d, mask) chainTable[(d) & mask]
|
||||||
|
|
||||||
/* Update chains up to ip (excluded)
|
/* Update chains up to ip (excluded)
|
||||||
Assumption : always within prefix (ie. not within extDict) */
|
Assumption : always within prefix (ie. not within extDict) */
|
||||||
static U32 ZSTD_insertAndFindFirstIndex (ZSTD_CCtx* zc, const BYTE* ip, U32 mls)
|
static U32 ZSTD_insertAndFindFirstIndex (ZSTD_CCtx* zc, const BYTE* ip, U32 mls)
|
||||||
{
|
{
|
||||||
|
@@ -229,7 +229,7 @@ static size_t findDiff(const void* buf1, const void* buf2, size_t max)
|
|||||||
# define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
|
# define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
|
||||||
DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; }
|
DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; }
|
||||||
|
|
||||||
static const U32 maxSrcLog = 23;
|
static const U32 maxSrcLog = 24;
|
||||||
static const U32 maxSampleLog = 19;
|
static const U32 maxSampleLog = 19;
|
||||||
|
|
||||||
int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibility)
|
int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibility)
|
||||||
@@ -313,8 +313,8 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
|
|||||||
/* Multi - segments compression test */
|
/* Multi - segments compression test */
|
||||||
XXH64_reset(&crc64, 0);
|
XXH64_reset(&crc64, 0);
|
||||||
nbChunks = (FUZ_rand(&lseed) & 127) + 2;
|
nbChunks = (FUZ_rand(&lseed) & 127) + 2;
|
||||||
sampleSizeLog = FUZ_rand(&lseed) % maxSrcLog;
|
maxTestSize = FUZ_rand(&lseed) % maxSrcLog;
|
||||||
maxTestSize = (size_t)1 << sampleSizeLog;
|
maxTestSize = (size_t)1 << maxTestSize;
|
||||||
maxTestSize += FUZ_rand(&lseed) & (maxTestSize-1);
|
maxTestSize += FUZ_rand(&lseed) & (maxTestSize-1);
|
||||||
ZBUFF_compressInit(zc, (FUZ_rand(&lseed) % (20 - (sampleSizeLog/3))) + 1);
|
ZBUFF_compressInit(zc, (FUZ_rand(&lseed) % (20 - (sampleSizeLog/3))) + 1);
|
||||||
totalTestSize = 0;
|
totalTestSize = 0;
|
||||||
@@ -334,9 +334,18 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
|
|||||||
errorCode = ZBUFF_compressContinue(zc, cBuffer+cSize, &genSize, srcBuffer+sampleStart, &readSize);
|
errorCode = ZBUFF_compressContinue(zc, cBuffer+cSize, &genSize, srcBuffer+sampleStart, &readSize);
|
||||||
CHECK (ZBUFF_isError(errorCode), "compression error : %s", ZBUFF_getErrorName(errorCode));
|
CHECK (ZBUFF_isError(errorCode), "compression error : %s", ZBUFF_getErrorName(errorCode));
|
||||||
CHECK (readSize != sampleSize, "compression test condition not respected : input should be fully consumed")
|
CHECK (readSize != sampleSize, "compression test condition not respected : input should be fully consumed")
|
||||||
|
|
||||||
cSize += genSize;
|
cSize += genSize;
|
||||||
totalTestSize += sampleSize;
|
totalTestSize += sampleSize;
|
||||||
|
|
||||||
|
if ((FUZ_rand(&lseed) & 15) == 0)
|
||||||
|
{
|
||||||
|
/* add a few random flushes operations, to mess around */
|
||||||
|
genSize = cBufferSize - cSize;
|
||||||
|
errorCode = ZBUFF_compressFlush(zc, cBuffer+cSize, &genSize);
|
||||||
|
CHECK (ZBUFF_isError(errorCode), "flush error : %s", ZBUFF_getErrorName(errorCode));
|
||||||
|
cSize += genSize;
|
||||||
|
}
|
||||||
|
|
||||||
if (totalTestSize > maxTestSize) break;
|
if (totalTestSize > maxTestSize) break;
|
||||||
}
|
}
|
||||||
genSize = cBufferSize - cSize;
|
genSize = cBufferSize - cSize;
|
||||||
|
Reference in New Issue
Block a user