comment bug on older versions of ZSTD_compress_destSize()
authorYann Collet <cyan@fb.com>
Fri, 18 Sep 2020 03:59:01 +0000 (20:59 -0700)
committerYann Collet <cyan@fb.com>
Fri, 18 Sep 2020 03:59:01 +0000 (20:59 -0700)
following investigation in #859

lib/lz4.h

index 5d2475c11f2bc4f772c26a07df596338bbc2afb2..5474005d73c3b8913df5ea566c15a24c42ac9823 100644 (file)
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -213,7 +213,18 @@ LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* d
  *               New value is necessarily <= input value.
  * @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
  *           or 0 if compression fails.
-*/
+ *
+ * Note : from v1.8.2 to v1.9.1, this function had a bug (fixed un v1.9.2+):
+ *        the produced compressed content could, in specific circumstances,
+ *        require to be decompressed into a destination buffer larger
+ *        by at least 1 byte than the content to decompress.
+ *        If an application uses `LZ4_compress_destSize()`,
+ *        it's highly recommended to update liblz4 to v1.9.2 or better.
+ *        If this can't be done or ensured,
+ *        the receiving decompression function should provide
+ *        a dstCapacity which is > decompressedSize, by at least 1 byte.
+ *        See https://github.com/lz4/lz4/issues/859 for details
+ */
 LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);