]> git.ipfire.org Git - thirdparty/zstd.git/commit
fixed decoder behavior when nbSeqs==0 is encoded using 2 bytes 3669/head
authorYann Collet <cyan@fb.com>
Mon, 5 Jun 2023 23:03:00 +0000 (16:03 -0700)
committerYann Collet <cyan@fb.com>
Mon, 5 Jun 2023 23:03:00 +0000 (16:03 -0700)
commit3732a08f5b82ed87a744e65daa2f11f77dabe954
tree89104c74882023317076b40364ed7bbdef717e16
parent3e815f5b3a3cff33ef9f9b284179928983b25935
fixed decoder behavior when nbSeqs==0 is encoded using 2 bytes

The sequence section starts with a number, which tells how sequences are present in the section.
If this number if 0, the section automatically ends.

The number 0 can be represented using the 1 byte or the 2 bytes formats.
That's because the 2-bytes formats fully overlaps the 1 byte format.

However, when 0 is represented using the 2-bytes format,
the decoder was expecting the sequence section to continue,
and was looking for FSE tables, which is incorrect.

Fixed this behavior, in both the reference decoder and the educational behavior.

In practice, this behavior never happens,
because the encoder will always select the 1-byte format to represent 0,
since this is more efficient.

Completed the fix with a new golden sample for tests,
a clarification of the specification,
and a decoder errata paragraph.
doc/decompressor_errata.md
doc/educational_decoder/zstd_decompress.c
doc/zstd_compression_format.md
lib/common/zstd_internal.h
lib/decompress/zstd_decompress_block.c
tests/golden-decompression/zeroSeq_2B.zst [new file with mode: 0644]