From: Yann Collet Date: Fri, 1 Aug 2014 18:10:21 +0000 (+0100) Subject: fix : HC streaming mode X-Git-Tag: upstream/1.9.3~259^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ac18ad9dc5a5555f9129659c007fe9141e422b0;p=platform%2Fupstream%2Flz4.git fix : HC streaming mode --- diff --git a/NEWS b/NEWS index 889273f..6ad8906 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ r121: Added : Makefile : install for kFreeBSD and Hurd (Nobuhiro Iwamatsu) +Fix : Makefile : install for OS-X and BSD, thanks to Takayuki Matsuoka r120: Modified : Streaming API, using strong types 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);