summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2018-09-05 21:07:53 (GMT)
committerGitHub <noreply@github.com>2018-09-05 21:07:53 (GMT)
commitdc32009ab1f0a6fca74998f5f3704d269c450aea (patch)
treee3e3bc01eb3e85cef21de88a0d87c80ff4dc81c8 /lib
parentc4dbc37b3ce085a05441124fee4a8144dc149b05 (diff)
parent30f6f34328733ec4e74c78c06f667810db0417df (diff)
downloadlz4-dc32009ab1f0a6fca74998f5f3704d269c450aea.zip
lz4-dc32009ab1f0a6fca74998f5f3704d269c450aea.tar.gz
lz4-dc32009ab1f0a6fca74998f5f3704d269c450aea.tar.bz2
Merge pull request #562 from lz4/roundTrip
Round trip test for #560
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4hc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index 8108ea0..e913ee7 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,7 @@ LZ4_FORCE_INLINE int LZ4HC_encodeSequence (
*op += length;
/* Encode Offset */
+ assert( (*ip - match) <= MAX_DISTANCE ); /* note : consider providing offset as a value, rather than as a pointer difference */
LZ4_writeLE16(*op, (U16)(*ip-match)); *op += 2;
/* Encode MatchLength */