]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fix out-of-bounds array index access
authorMingjie Shen <shen497@purdue.edu>
Mon, 13 Jan 2025 21:39:34 +0000 (16:39 -0500)
committerGitHub <noreply@github.com>
Mon, 13 Jan 2025 21:39:34 +0000 (16:39 -0500)
lib/compress/zstd_compress.c

index 04b6bb9f1113abb3561342d72587578ae546dccf..ef1817f5214b14b5de2020322295c576107edd14 100644 (file)
@@ -6713,7 +6713,7 @@ ZSTD_transferSequences_wBlockDelim(ZSTD_CCtx* cctx,
 
     ZSTD_memcpy(cctx->blockState.nextCBlock->rep, updatedRepcodes.rep, sizeof(Repcodes_t));
 
-    if (inSeqs[idx].litLength) {
+    if (idx < inSeqsSize && 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;