Correction : LZ4_compress_limitedOutput() write too far error

git-svn-id: https://lz4.googlecode.com/svn/trunk@77 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
yann.collet.73@gmail.com 2012-08-22 15:59:39 +00:00
parent f4e48fe61d
commit 9577c977a9

2
lz4.c
View File

@ -449,6 +449,7 @@ _endCount:
// Encode MatchLength // Encode MatchLength
len = (int)(ip - anchor); len = (int)(ip - anchor);
if unlikely(op + (1 + LASTLITERALS) + (len>>8) >= oend) return 0; // Check output limit
if (len>=(int)ML_MASK) { *token+=ML_MASK; len-=ML_MASK; for(; len > 509 ; len-=510) { *op++ = 255; *op++ = 255; } if (len > 254) { len-=255; *op++ = 255; } *op++ = (BYTE)len; } if (len>=(int)ML_MASK) { *token+=ML_MASK; len-=ML_MASK; for(; len > 509 ; len-=510) { *op++ = 255; *op++ = 255; } if (len > 254) { len-=255; *op++ = 255; } *op++ = (BYTE)len; }
else *token += len; else *token += len;
@ -613,6 +614,7 @@ _endCount:
// Encode MatchLength // Encode MatchLength
len = (int)(ip - anchor); len = (int)(ip - anchor);
if unlikely(op + (1 + LASTLITERALS) + (len>>8) >= oend) return 0; // Check output limit
if (len>=(int)ML_MASK) { *token+=ML_MASK; len-=ML_MASK; for(; len > 509 ; len-=510) { *op++ = 255; *op++ = 255; } if (len > 254) { len-=255; *op++ = 255; } *op++ = (BYTE)len; } if (len>=(int)ML_MASK) { *token+=ML_MASK; len-=ML_MASK; for(; len > 509 ; len-=510) { *op++ = 255; *op++ = 255; } if (len > 254) { len-=255; *op++ = 255; } *op++ = (BYTE)len; }
else *token += len; else *token += len;