last match will start at a minimum distance of 8 from oend
diff --git a/lib/zstd_decompress.c b/lib/zstd_decompress.c
index c9946f5..31d1fd0 100644
--- a/lib/zstd_decompress.c
+++ b/lib/zstd_decompress.c
@@ -708,7 +708,7 @@
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 */
diff --git a/lib/zstd_opt.c b/lib/zstd_opt.c
index 0510e94..8221bd2 100644
--- a/lib/zstd_opt.c
+++ b/lib/zstd_opt.c
@@ -383,7 +383,7 @@
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 @@
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 @@
if (cur == last_pos) break;
-
+ if (inr > ilimit)
+ continue;
mlen = opt[cur].mlen;
@@ -912,7 +912,7 @@
/* 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;