]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
last match will start at a minimum distance of 8 from oend
authorinikep <inikep@gmail.com>
Thu, 4 Feb 2016 20:16:07 +0000 (21:16 +0100)
committerinikep <inikep@gmail.com>
Thu, 4 Feb 2016 20:16:07 +0000 (21:16 +0100)
lib/zstd_decompress.c
lib/zstd_opt.c

index c9946f5fc24718c71e506752d5234a09e42d7859..31d1fd07ca288e2dcba0add58b52990eabcad6b9 100644 (file)
@@ -708,7 +708,7 @@ FORCE_INLINE size_t ZSTD_execSequence(BYTE* op,
     const BYTE* match = oLitEnd - sequence.offset;
 
     /* check */
-  //  if (oLitEnd > oend_8) return ERROR(dstSize_tooSmall);   /* last match must start at a minimum distance of 8 from oend */
+    if (oLitEnd > oend_8) return ERROR(dstSize_tooSmall);   /* last match must start at a minimum distance of 8 from oend */
     if (oMatchEnd > oend) return ERROR(dstSize_tooSmall);   /* overwrite beyond dst buffer */
     if (litEnd > litLimit_8) return ERROR(corruption_detected);   /* risk read beyond lit buffer */
 
index 0510e945ed59c59f7b790f3944f2a41431c67301..8221bd2501f7e7a5cc84e184d696d5a7912b0fee 100644 (file)
@@ -383,7 +383,7 @@ size_t ZSTD_HcGetAllMatches_generic (
             while ((start > iLowLimit) && (start > base+offset) && (start[-1] == start[-1-offset])) start--; 
             back = ip - start;
 #else
-            while ((match-back > base) && (ip-back > iLowLimit) && (ip[-back-1] == match[-back-1])) back++;
+      //      while ((match-back > base) && (ip-back > iLowLimit) && (ip[-back-1] == match[-back-1])) back++;
 #endif
             currentMl += back;
         } else {
@@ -654,7 +654,6 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
             ZSTD_LOG_PARSER("%d: start try REP rep=%d mlen=%d\n", (int)(ip-base), (int)rep_1, (int)mlen);
             if (depth==0 || mlen > sufficient_len || mlen >= ZSTD_OPT_NUM) {
                 ip+=1; best_mlen = mlen; best_off = 0; cur = 0; last_pos = 1;
-                opt[0].rep = rep_1;
                 goto _storeSequence;
             }
 
@@ -748,7 +747,8 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
 
            if (cur == last_pos) break;
 
-
+           if (inr > ilimit)
+               continue;
 
             mlen = opt[cur].mlen;
             
@@ -912,7 +912,7 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
         /* store sequence */
 _storeSequence: // cur, last_pos, best_mlen, best_off have to be set
         for (int i = 1; i <= last_pos; i++)
-            ZSTD_LOG_PARSER("%d: price[%d/%d]=%d off=%d mlen=%d litlen=%d rep=%d rep2=%d back=%d\n", (int)(ip-base+i), i, last_pos, opt[i].price, opt[i].off, opt[i].mlen, opt[i].litlen, opt[i].rep, opt[i].rep2, opt[i].back);
+            ZSTD_LOG_PARSER("%d: price[%d/%d]=%d off=%d mlen=%d litlen=%d rep=%d rep2=%d\n", (int)(ip-base+i), i, last_pos, opt[i].price, opt[i].off, opt[i].mlen, opt[i].litlen, opt[i].rep, opt[i].rep2);
         ZSTD_LOG_PARSER("%d: cur=%d/%d best_mlen=%d best_off=%d rep=%d\n", (int)(ip-base+cur), (int)cur, (int)last_pos, (int)best_mlen, (int)best_off, opt[cur].rep); 
 
         opt[0].mlen = 1;