From d64d5ddc57ac58f3bcff2bd531cbe1e71bc4e356 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 27 Jan 2022 14:54:18 -0800 Subject: [PATCH] fix 44122 test error It's a bug in the test itself, in exceptional circumstances (no more space for additional sequence). There should be enough room for all cases to work fine from now on, and if not, we have an additional `assert()` to catch that situation. --- tests/fuzz/sequence_compression_api.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/fuzz/sequence_compression_api.c b/tests/fuzz/sequence_compression_api.c index b35f5a795..443e0a181 100644 --- a/tests/fuzz/sequence_compression_api.c +++ b/tests/fuzz/sequence_compression_api.c @@ -153,7 +153,7 @@ static size_t generateRandomSequences(FUZZ_dataProducer_t* producer, matchLengthMax = MIN(matchLengthMax, blockSizeMax/2); } - while ( nbSeqGenerated < ZSTD_FUZZ_MAX_NBSEQ-1 + while ( nbSeqGenerated < ZSTD_FUZZ_MAX_NBSEQ-2 /* extra room for explicit delimiters */ && bytesGenerated < ZSTD_FUZZ_GENERATED_SRC_MAXSIZE && !FUZZ_dataProducer_empty(producer)) { uint32_t matchLength; @@ -214,6 +214,7 @@ static size_t generateRandomSequences(FUZZ_dataProducer_t* producer, if (mode == ZSTD_sf_explicitBlockDelimiters) { /* always end sequences with a block delimiter */ const ZSTD_Sequence endBlock = {0, 0, 0, 0}; + assert(nbSeqGenerated < ZSTD_FUZZ_MAX_NBSEQ); generatedSequences[nbSeqGenerated++] = endBlock; }