Skip to content

Commit

Permalink
add one valid test case
Browse files Browse the repository at this point in the history
ZSTD_compressSequencesAndLiterals() may return a specific error code
when data to compress is non-compressible.
  • Loading branch information
Cyan4973 committed Dec 24, 2024
1 parent f8725e8 commit 7b294ca
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/fuzz/sequence_compression_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#define ZSTD_STATIC_LINKING_ONLY
#include "zstd_errors.h"

#include <stddef.h>
#include <stdlib.h>
Expand Down Expand Up @@ -275,7 +276,12 @@ static size_t roundTripTest_compressSequencesAndLiterals(
return 0;
}
/* round-trip */
FUZZ_ZASSERT(cSize);
if (ZSTD_isError(cSize)) {
ZSTD_ErrorCode err = ZSTD_getErrorCode(cSize);
/* this specific error might happen as a result of data being uncompressible */
if (err != ZSTD_error_cannotProduce_uncompressedBlock)
FUZZ_ZASSERT(cSize);
}
{ size_t const dSize = ZSTD_decompressDCtx(dctx, result, resultCapacity, compressed, cSize);
FUZZ_ZASSERT(dSize);
FUZZ_ASSERT_MSG(dSize == srcSize, "Incorrect regenerated size");
Expand Down

0 comments on commit 7b294ca

Please sign in to comment.