summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2018-09-05 01:21:40 (GMT)
committerYann Collet <cyan@fb.com>2018-09-05 01:21:40 (GMT)
commit2e4847c2d55fb4c4f5dc833e61b5f374da8407e6 (patch)
treea596da5254cfdb5b726db9e46fa72379d6c69d35 /lib
parent943fa6244a3985541bc93250d35ea4f4517fb266 (diff)
downloadlz4-2e4847c2d55fb4c4f5dc833e61b5f374da8407e6.zip
lz4-2e4847c2d55fb4c4f5dc833e61b5f374da8407e6.tar.gz
lz4-2e4847c2d55fb4c4f5dc833e61b5f374da8407e6.tar.bz2
fixed #560
it was a fairly complex scenario, involving source files > 64K and some extraordinary conditions related to specific layout of ranges of zeroes. and only on level 9.
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4hc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index 8108ea0..236dc5b 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -327,6 +327,8 @@ LZ4HC_InsertAndGetWiderMatch (
if (lookBackLength==0) { /* no back possible */
size_t const maxML = MIN(currentSegmentLength, srcPatternLength);
if ((size_t)longest < maxML) {
+ assert(base + matchIndex < ip);
+ if (ip - (base+matchIndex) > MAX_DISTANCE) break;
assert(maxML < 2 GB);
longest = (int)maxML;
*matchpos = base + matchIndex; /* virtual pos, relative to ip, to retrieve offset */
@@ -450,6 +452,8 @@ LZ4_FORCE_INLINE int LZ4HC_encodeSequence (
*op += length;
/* Encode Offset */
+ assert(*ip > match);
+ assert( (*ip - match) <= MAX_DISTANCE );
LZ4_writeLE16(*op, (U16)(*ip-match)); *op += 2;
/* Encode MatchLength */