Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/decompress/zstd_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions tests/fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down