Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compression: Allocate memory for compressEnd
Before this change the code assumed that the destination temp. buffer always had enough free space for LZ4F_compressEnd operation. This change checks the free size before calling LZ4F_compressEnd and allocates a new buffer if necessary. Note that the free space required is computed using LZ4F_compressBound with a srcSize of 0. By looking at LZ4F_compressEnd it may appear that we can just check if 12 bytes are free in the destination buffer, whereas LZ4F_compressBound always assumes at least 65443 ie 65535 + block header size (4) + frame footer (4). However, lz4frame docstring for LZ4F_compressBound states that: "When srcSize==0, LZ4F_compressBound() provides an upper bound for LZ4F_flush() and LZ4F_compressEnd() instead." Similar directions are mentioned on LZ4 gh issues, so it is safer to be conservative and possibly allocate the extra bytes. (cherry picked from commit 1493c6d)
- Loading branch information