From: Paul Cruz Date: Fri, 23 Jun 2017 22:54:51 +0000 (-0700) Subject: added additional condition so large offsets into the dictionary are not generated... X-Git-Tag: v1.3.0~1^2~15^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a295a91f8c8645888d7701eeb4c813c8fd663b8;p=thirdparty%2Fzstd.git added additional condition so large offsets into the dictionary are not generated past windowSize --- diff --git a/tests/decodecorpus.c b/tests/decodecorpus.c index eaeb05eac..9e5e973ca 100644 --- a/tests/decodecorpus.c +++ b/tests/decodecorpus.c @@ -675,11 +675,12 @@ static U32 generateSequences(U32* seed, frame_t* frame, seqStore_t* seqStore, do { if (RAND(seed) & 7) { /* do a normal offset */ + U32 const dataDecompressed = (U32)((BYTE*)srcPtr-(BYTE*)frame->srcStart); offset = (RAND(seed) % MIN(frame->header.windowSize, (size_t)((BYTE*)srcPtr - (BYTE*)frame->srcStart))) + 1; - if (info.useDict && (RAND(seed) & 1) && i + 1 != numSequences) { + if (info.useDict && (RAND(seed) & 1) && i + 1 != numSequences && dataDecompressed < frame->header.windowSize) { /* need to occasionally generate offsets that go past the start */ /* including i+1 != numSequences because the last sequences has to adhere to predetermined contentSize */ U32 lenPastStart = (RAND(seed) % info.dictContentSize) + 1;