summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lz4.c')
-rw-r--r--lib/lz4.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 915ee74..a18401a 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1592,11 +1592,26 @@ LZ4_decompress_generic(
length += read_variable_length(&ip, iend - LASTLITERALS + 1, endOnInput, 0, &error);
if (error != ok) goto _output_error;
if ((safeDecode) && unlikely((uptrval)(op)+length<(uptrval)op)) goto _output_error; /* overflow detection */
- }
- length += MINMATCH;
+ length += MINMATCH;
+ if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) {
+ goto safe_match_copy;
+ }
+ } else {
+ length += MINMATCH;
+ if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) {
+ goto safe_match_copy;
+ }
- if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) {
- goto safe_match_copy;
+ /* Fastpath check: Avoids a branch in LZ4_wildCopy16 if true */
+ if (!(dict == usingExtDict) || (match >= lowPrefix)) {
+ if (offset >= 8) {
+ memcpy(op, match, 8);
+ memcpy(op+8, match+8, 8);
+ memcpy(op+16, match+16, 2);
+ op += length;
+ continue;
+ }
+ }
}
/* match starting within external dictionary */