]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
return error if block delimiter is not found 4238/head
authorMingjie Shen <shen497@purdue.edu>
Tue, 14 Jan 2025 01:52:06 +0000 (20:52 -0500)
committerGitHub <noreply@github.com>
Tue, 14 Jan 2025 01:52:06 +0000 (20:52 -0500)
lib/compress/zstd_compress.c

index ef1817f5214b14b5de2020322295c576107edd14..e033a04ccc429ad227ce4c6c880840b05a54a892 100644 (file)
@@ -6687,6 +6687,7 @@ ZSTD_transferSequences_wBlockDelim(ZSTD_CCtx* cctx,
         ZSTD_storeSeq(&cctx->seqStore, litLength, ip, iend, offBase, matchLength);
         ip += matchLength + litLength;
     }
+    RETURN_ERROR_IF(idx == inSeqsSize, externalSequences_invalid, "Block delimiter not found.");
 
     /* If we skipped repcode search while parsing, we need to update repcodes now */
     assert(externalRepSearch != ZSTD_ps_auto);
@@ -6713,7 +6714,7 @@ ZSTD_transferSequences_wBlockDelim(ZSTD_CCtx* cctx,
 
     ZSTD_memcpy(cctx->blockState.nextCBlock->rep, updatedRepcodes.rep, sizeof(Repcodes_t));
 
-    if (idx < inSeqsSize && inSeqs[idx].litLength) {
+    if (inSeqs[idx].litLength) {
         DEBUGLOG(6, "Storing last literals of size: %u", inSeqs[idx].litLength);
         ZSTD_storeLastLiterals(&cctx->seqStore, ip, inSeqs[idx].litLength);
         ip += inSeqs[idx].litLength;