1
0
mirror of https://github.com/lz4/lz4.git synced 2026-10-24 01:48:57 +03:00

lz4.h: ring buffer conditions of LZ4_decompress_safe_continue()

Synchronized mode : decoding needs the exact decompressed size of every block, including the last one.
Decoding may write up to dst + dstCapacity, over data still referenced.

Decoding ring larger than the encoding one : the margin must be maxBlockSize + 64 bytes, instead of maxBlockSize.
Since v1.9.0, with dstCapacity > block size, a block ending with a wide copy can write
up to 63 bytes beyond its end (LZ4_wildCopy64), over the oldest data a later block may still reference.
Same margin as LZ4_DECODER_RING_BUFFER_SIZE().
This commit is contained in:
Yann Collet
2026-10-12 19:32:21 -07:00
parent b4ee63fedc
commit 2f449bb3a0

View File

@@ -521,9 +521,10 @@ LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
* - Synchronized mode :
* Decompression buffer size is _exactly_ the same as compression buffer size,
* and follows exactly same update rule (block boundaries at same positions),
* and decoding function is provided with exact decompressed size of each block (exception for last block of the stream),
* and decoding function is provided with exact decompressed size of each block, including the last one
* (decoding may write up to dst + dstCapacity, over data still referenced),
* _then_ decoding & encoding ring buffer can have any size, including small ones ( < 64 KB).
* - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes.
* - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize + 64 bytes.
* In which case, encoding and decoding buffers do not need to be synchronized,
* and encoding ring buffer can have any size, including small ones ( < 64 KB).
*