summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2016-06-29 11:21:23 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2016-06-29 11:21:23 (GMT)
commitc77c0c1086bf55342da95a7e94021be860919771 (patch)
tree293b724201339c2516b671594d82d61fc809235f
parent3c0332600490003b1267a9f0a51a6a315b52891e (diff)
downloadlz4-c77c0c1086bf55342da95a7e94021be860919771.zip
lz4-c77c0c1086bf55342da95a7e94021be860919771.tar.gz
lz4-c77c0c1086bf55342da95a7e94021be860919771.tar.bz2
minor refactoring
-rw-r--r--lib/lz4.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index a8d3bce..89eef2f 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -495,7 +495,7 @@ FORCE_INLINE int LZ4_compress_generic(
size_t refDelta=0;
/* Init conditions */
- if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported input size, too large (or negative) */
+ if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported inputSize, too large (or negative) */
switch(dict)
{
case noDict:
@@ -559,11 +559,12 @@ FORCE_INLINE int LZ4_compress_generic(
/* Encode Literals */
{ unsigned const litLength = (unsigned)(ip - anchor);
token = op++;
- if ((outputLimited) && (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit)))
- return 0; /* Check output limit */
- if (litLength>=RUN_MASK) {
+ if ((outputLimited) && /* Check output buffer overflow */
+ (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit)))
+ return 0;
+ if (litLength >= RUN_MASK) {
int len = (int)litLength-RUN_MASK;
- *token=(RUN_MASK<<ML_BITS);
+ *token = (RUN_MASK<<ML_BITS);
for(; len >= 255 ; len-=255) *op++ = 255;
*op++ = (BYTE)len;
}
@@ -598,9 +599,10 @@ _next_match:
ip += MINMATCH + matchCode;
}
- if ((outputLimited) && (unlikely(op + (1 + LASTLITERALS) + (matchCode>>8) > olimit)))
- return 0; /* Check output limit */
- if (matchCode>=ML_MASK) {
+ if ( outputLimited && /* Check output buffer overflow */
+ (unlikely(op + (1 + LASTLITERALS) + (matchCode>>8) > olimit)) )
+ return 0;
+ if (matchCode >= ML_MASK) {
*token += ML_MASK;
matchCode -= ML_MASK;
for (; matchCode >= 510 ; matchCode-=510) { *op++ = 255; *op++ = 255; }