summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/lz4.c4
-rw-r--r--lib/lz4frame.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index a1d1860..076565a 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1708,10 +1708,9 @@ LZ4_decompress_generic(
/* get matchlength */
length = token & ML_MASK;
- if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) { goto _output_error; } /* Error : offset outside buffers */
-
if (length == ML_MASK) {
variable_length_error error = ok;
+ if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) { goto _output_error; } /* Error : offset outside buffers */
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 */
@@ -1735,6 +1734,7 @@ LZ4_decompress_generic(
continue;
} } }
+ if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) { goto _output_error; } /* Error : offset outside buffers */
/* match starting within external dictionary */
if ((dict==usingExtDict) && (match < lowPrefix)) {
if (unlikely(op+length > oend-LASTLITERALS)) {
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index 95b8b8e..cc7f2d5 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -1494,7 +1494,7 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
/* next block is a compressed block */
dctx->tmpInTarget = nextCBlockSize + crcSize;
dctx->dStage = dstage_getCBlock;
- if (dstPtr==dstEnd) {
+ if (dstPtr==dstEnd || srcPtr==srcEnd) {
nextSrcSizeHint = BHSize + nextCBlockSize + crcSize;
doAnotherStage = 0;
}