diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index 325f0b54dfc..59318f38d7f 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -1645,6 +1645,8 @@ unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize) ZSTD_FrameHeader zfp = { 0, 0, 0, ZSTD_frame, 0, 0, 0, 0, 0 }; size_t const hError = ZSTD_getFrameHeader(&zfp, src, srcSize); if (ZSTD_isError(hError)) return 0; + /* for skippable frames, dictID holds the magic variant : no dictionary is required */ + if (zfp.frameType == ZSTD_skippableFrame) return 0; return zfp.dictID; } diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 32360b9a58d..e00621a74b9 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -2814,6 +2814,18 @@ static int basicUnitTests(U32 const seed, double compressibility) } DISPLAYLEVEL(3, "OK \n"); + DISPLAYLEVEL(3, "test%3i : skippable frames don't require a dictionary : ", testNb++); + { unsigned magicVariant; + for (magicVariant = 0; magicVariant < 16; magicVariant++) { + size_t const skippableSize = ZSTD_writeSkippableFrame( + compressedBuffer, compressedBufferSize, + CNBuffer, 10, magicVariant); + CHECK_Z(skippableSize); + CHECK_EQ(0, ZSTD_getDictID_fromFrame(compressedBuffer, skippableSize)); + } + } + DISPLAYLEVEL(3, "OK \n"); + /* Dictionary and CCtx Duplication tests */ { ZSTD_CCtx* const ctxOrig = ZSTD_createCCtx(); ZSTD_CCtx* const ctxDuplicated = ZSTD_createCCtx();