]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added additional condition so large offsets into the dictionary are not generated...
authorPaul Cruz <paulcruz74@fb.com>
Fri, 23 Jun 2017 22:54:51 +0000 (15:54 -0700)
committerPaul Cruz <paulcruz74@fb.com>
Fri, 23 Jun 2017 22:54:51 +0000 (15:54 -0700)
tests/decodecorpus.c

index eaeb05eac1e31f6f423b965a2bcebbaa72db2bf0..9e5e973caf8f6868210ca5f3854cb1474137c985 100644 (file)
@@ -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;