fixed asan

dev
Yann Collet 2015-11-20 12:46:08 +01:00
parent 55aa7f94e3
commit 402fdcf1a3
2 changed files with 119 additions and 120 deletions

View File

@ -923,13 +923,13 @@ size_t ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx,
while (ip <= ilimit)
{
U32 current2 = (U32)(ip-base);
U32 repIndex2 = current2 - offset_2;
const U32 repIndex2 = current2 - offset_2;
const BYTE* repMatch2 = repIndex2 < dictLimit ? dictBase + repIndex2 : base + repIndex2;
if ( ((repIndex2 <= dictLimit-4) || (repIndex2 >= dictLimit))
&& (MEM_read32(repMatch2) == MEM_read32(ip)) )
{
size_t maxIlength = iend - ip;
size_t maxMlength = repIndex2 < dictLimit ? dictLimit - repIndex2 : iend - repMatch2;
size_t maxMlength = repIndex2 < dictLimit ? (size_t)(dictLimit - repIndex2) : (size_t)(iend - repMatch2);
size_t maxML = MIN(maxMlength, maxIlength);
size_t ml = ZSTD_count(ip+MINMATCH, repMatch2+MINMATCH, ip + maxML);
U32 tmpOff = offset_2; offset_2 = offset_1; offset_1 = tmpOff; /* swap offset_2 <=> offset_1 */

View File

@ -81,7 +81,6 @@ typedef BYTE litDistribTable[LTSIZE];
/*********************************************************
* Local Functions
*********************************************************/
@ -130,7 +129,7 @@ static BYTE RDG_genChar(U32* seed, const litDistribTable lt)
}
#define RDG_RAND15BITS ((RDG_rand(seed) >> 3) & 32767)
#define RDG_RAND15BITS ((RDG_rand(seed) >> 3) & 0x7FFF)
#define RDG_RANDLENGTH ( ((RDG_rand(seed) >> 7) & 7) ? (RDG_rand(seed) & 15) : (RDG_rand(seed) & 511) + 15)
void RDG_genBlock(void* buffer, size_t buffSize, size_t prefixSize, double matchProba, litDistribTable lt, unsigned* seedPtr)
{
@ -168,16 +167,16 @@ void RDG_genBlock(void* buffer, size_t buffSize, size_t prefixSize, double match
{
/* Copy (within 32K) */
size_t match;
size_t length = RDG_RANDLENGTH + 4;
size_t d;
int length = RDG_RANDLENGTH + 4;
U32 offset = RDG_RAND15BITS + 1;
U32 repeatOffset = (RDG_rand(seed) & 15) == 2;
if (repeatOffset) offset = prevOffset;
if (offset > pos) offset = (U32)pos;
match = pos - offset;
if (length > buffSize-pos) length = buffSize-pos;
memcpy(buffPtr+pos, buffPtr+match, length);
pos += length;
prevOffset = offset;
d = pos + length;
if (d > buffSize) d = buffSize;
while (pos < d) buffPtr[pos++] = buffPtr[match++]; /* correctly manages overlaps */
}
else
{