summaryrefslogtreecommitdiffstats
path: root/lz4hc.c
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2014-08-01 18:10:21 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2014-08-01 18:10:21 (GMT)
commit7ac18ad9dc5a5555f9129659c007fe9141e422b0 (patch)
tree9e6b4627c32f33ac6a5212afbcce9e3a66270d98 /lz4hc.c
parent17fdc54813582d3235401f287999cc17c466ab5f (diff)
downloadlz4-7ac18ad9dc5a5555f9129659c007fe9141e422b0.zip
lz4-7ac18ad9dc5a5555f9129659c007fe9141e422b0.tar.gz
lz4-7ac18ad9dc5a5555f9129659c007fe9141e422b0.tar.bz2
fix : HC streaming mode
Diffstat (limited to 'lz4hc.c')
-rw-r--r--lz4hc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lz4hc.c b/lz4hc.c
index 6086749..7de9811 100644
--- a/lz4hc.c
+++ b/lz4hc.c
@@ -400,7 +400,10 @@ FORCE_INLINE void LZ4HC_Insert (LZ4HC_Data_Structure* hc4, const BYTE* ip)
char* LZ4_slideInputBufferHC(void* LZ4HC_Data)
{
LZ4HC_Data_Structure* hc4 = (LZ4HC_Data_Structure*)LZ4HC_Data;
- U32 distance = (U32)(hc4->end - hc4->inputBuffer) - 64 KB;
+ size_t distance = (hc4->end - 64 KB) - hc4->inputBuffer;
+
+ if (hc4->end <= hc4->inputBuffer + 64 KB) return (char*)(hc4->end); /* no update : less than 64KB within buffer */
+
distance = (distance >> 16) << 16; /* Must be a multiple of 64 KB */
LZ4HC_Insert(hc4, hc4->end - MINMATCH);
memcpy((void*)(hc4->end - 64 KB - distance), (const void*)(hc4->end - 64 KB), 64 KB);