summaryrefslogtreecommitdiffstats
path: root/lib/lz4frame.h
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2018-10-09 21:25:18 (GMT)
committerYann Collet <cyan@fb.com>2018-10-09 21:25:18 (GMT)
commite07a37d712c87b6d47d043b018e4ff86d31996b3 (patch)
tree6a57d3578cf0827434e23dfc4a77ea5bc90dfe41 /lib/lz4frame.h
parenta963621eb0938a991c417ec75cbfe85bee684fdd (diff)
downloadlz4-e07a37d712c87b6d47d043b018e4ff86d31996b3.zip
lz4-e07a37d712c87b6d47d043b018e4ff86d31996b3.tar.gz
lz4-e07a37d712c87b6d47d043b018e4ff86d31996b3.tar.bz2
added a test for LZ4F_compressEnd()
which actively tries to make it write out of bound. For this scenario to be possible, it's necessary to set dstCapacity < LZ4F_compressBound() When a compression operation fails, the CCtx context is left in an undefined state, therefore compression cannot resume. As a consequence : - round trip tests must be aborted, since there is nothing valid to decompress - most users avoid this situation, by ensuring that dstCapacity >= LZ4F_compressBound() For these reasons, this use case was poorly tested up to now.
Diffstat (limited to 'lib/lz4frame.h')
-rw-r--r--lib/lz4frame.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/lz4frame.h b/lib/lz4frame.h
index fc30f6f..599f17e 100644
--- a/lib/lz4frame.h
+++ b/lib/lz4frame.h
@@ -295,6 +295,7 @@ LZ4FLIB_API size_t LZ4F_compressUpdate(LZ4F_cctx* cctx,
* `cOptPtr` is optional : it's possible to provide NULL, all options will be set to default.
* @return : nb of bytes written into dstBuffer (can be zero, when there is no data stored within cctx)
* or an error code if it fails (which can be tested using LZ4F_isError())
+ * Note : LZ4F_flush() is guaranteed to be successful when dstCapacity >= LZ4F_compressBound(0, prefsPtr).
*/
LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx* cctx,
void* dstBuffer, size_t dstCapacity,
@@ -307,6 +308,7 @@ LZ4FLIB_API size_t LZ4F_flush(LZ4F_cctx* cctx,
* `cOptPtr` is optional : NULL can be provided, in which case all options will be set to default.
* @return : nb of bytes written into dstBuffer, necessarily >= 4 (endMark),
* or an error code if it fails (which can be tested using LZ4F_isError())
+ * Note : LZ4F_compressEnd() is guaranteed to be successful when dstCapacity >= LZ4F_compressBound(0, prefsPtr).
* A successful call to LZ4F_compressEnd() makes `cctx` available again for another compression task.
*/
LZ4FLIB_API size_t LZ4F_compressEnd(LZ4F_cctx* cctx,