Fix Offset Math
authorW. Felix Handte <w@felixhandte.com>
Thu, 5 Apr 2018 20:32:40 +0000 (16:32 -0400)
committerW. Felix Handte <w@felixhandte.com>
Fri, 20 Apr 2018 00:54:35 +0000 (20:54 -0400)
lib/lz4hc.c

index 4a52f0c..5479159 100644 (file)
@@ -93,12 +93,13 @@ static void LZ4HC_clearTables (LZ4HC_CCtx_internal* hc4)
 
 static void LZ4HC_init (LZ4HC_CCtx_internal* hc4, const BYTE* start)
 {
-    U32 startingOffset = hc4->end - hc4->base + 64 KB;
+    uptrval startingOffset = hc4->end - hc4->base;
     DEBUGLOG(4, "LZ4HC_init(%p, %p)", hc4, start);
     if (startingOffset > 1 GB || startingOffset > (uptrval)start) {
         MEM_INIT((void*)hc4->hashTable, 0, sizeof(hc4->hashTable));
-        startingOffset = 64 KB;
+        startingOffset = 0;
     }
+    startingOffset += MAX_DISTANCE;
     hc4->nextToUpdate = startingOffset;
     hc4->base = start - startingOffset;
     hc4->end = start;