From: yann.collet.73@gmail.com Date: Thu, 22 Sep 2011 13:11:17 +0000 (+0000) Subject: Corrected issue 3 in compression function. Update is recommended. X-Git-Tag: upstream/1.9.3~355 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=307128134089c807a9f86dfe6c3dc665982f329a;p=platform%2Fupstream%2Flz4.git Corrected issue 3 in compression function. Update is recommended. git-svn-id: https://lz4.googlecode.com/svn/trunk@26 650e7d94-2a16-8b24-b05c-7c0b3f6821cd --- diff --git a/lz4.c b/lz4.c index fdf4fdd..ffc97b3 100644 --- a/lz4.c +++ b/lz4.c @@ -66,6 +66,7 @@ // Constants //************************************** #define MINMATCH 4 +#define MINLENGTH 6 #define SKIPSTRENGTH 6 #define STACKLIMIT 13 #define HEAPMODE (HASH_LOG>STACKLIMIT) // Defines if memory is allocated into the stack (local variable), or into the heap (malloc()). @@ -118,7 +119,8 @@ int LZ4_compressCtx(void** ctx, const BYTE* ip = (BYTE*) source; const BYTE* anchor = ip; const BYTE* const iend = ip + isize; - const BYTE* const ilimit = iend - MINMATCH; + const BYTE* const ilm = iend - 1; + const BYTE* const ilimit = iend - MINMATCH - 1; BYTE* op = (BYTE*) dest; BYTE* token; @@ -130,6 +132,7 @@ int LZ4_compressCtx(void** ctx, // Init + if (isize ilimit) { anchor = ip; break; } + if (ip > ilimit-1) { anchor = ip; break; } // Test next position ref = HashTable[HASH_VALUE(ip)]; @@ -221,14 +224,13 @@ _endCount: _last_literals: // Encode Last Literals - if (anchor < iend) { int lastLitRun = iend - anchor; if (lastLitRun>=(int)RUN_MASK) { *op++=(RUN_MASK< 254 ; lastLitRun-=255) *op++ = 255; *op++ = (BYTE) lastLitRun; } else *op++ = (lastLitRun<