summaryrefslogtreecommitdiffstats
path: root/lib/lz4hc.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2019-12-03 22:49:22 (GMT)
committerYann Collet <cyan@fb.com>2019-12-03 22:49:22 (GMT)
commitd755f87f9fb7d625cdb9c9b54ab02e451cd80e9e (patch)
tree311b035c09add59f2e7e18b3b4dabb951bfbd704 /lib/lz4hc.c
parent0f6cbd996fbaade6715c7009c6f8dbb0f23f0b4b (diff)
downloadlz4-d755f87f9fb7d625cdb9c9b54ab02e451cd80e9e.zip
lz4-d755f87f9fb7d625cdb9c9b54ab02e451cd80e9e.tar.gz
lz4-d755f87f9fb7d625cdb9c9b54ab02e451cd80e9e.tar.bz2
fixed lz4hc assert error
when src ptr is in very low memory area (< 64K), the virtual reference to data in dictionary might end up in a very high memory address. Since it's not a "real" memory address, just a virtual one, to calculate distance, it doesn't matter : only distance matters. The assert was to restrictive. Fixed.
Diffstat (limited to 'lib/lz4hc.c')
-rw-r--r--lib/lz4hc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index 5922ed7..afadb3f 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -389,8 +389,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) > LZ4_DISTANCE_MAX) break;
+ assert(base + matchIndex != ip);
+ if ((size_t)(ip - base) - matchIndex > LZ4_DISTANCE_MAX) break;
assert(maxML < 2 GB);
longest = (int)maxML;
*matchpos = base + matchIndex; /* virtual pos, relative to ip, to retrieve offset */
@@ -1028,7 +1028,7 @@ int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr,
const char* dictionary, int dictSize)
{
LZ4HC_CCtx_internal* const ctxPtr = &LZ4_streamHCPtr->internal_donotuse;
- DEBUGLOG(4, "LZ4_loadDictHC(%p, %p, %d)", LZ4_streamHCPtr, dictionary, dictSize);
+ DEBUGLOG(4, "LZ4_loadDictHC(ctx:%p, dict:%p, dictSize:%d)", LZ4_streamHCPtr, dictionary, dictSize);
assert(LZ4_streamHCPtr != NULL);
if (dictSize > 64 KB) {
dictionary += (size_t)dictSize - 64 KB;