From 57c35511d4a0053576468a23837de43fc293d923 Mon Sep 17 00:00:00 2001 From: Christopher Harvie Date: Wed, 13 May 2020 21:48:12 -0400 Subject: fix LZ4F_compressBound when automatic flushing is enabled --- lib/lz4frame.c | 3 +++ lib/lz4frame.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/lz4frame.c b/lib/lz4frame.c index c9f630d..5d716ea 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -725,6 +725,9 @@ size_t LZ4F_compressBegin(LZ4F_cctx* cctxPtr, */ size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr) { + if (preferencesPtr && preferencesPtr->autoFlush) { + return LZ4F_compressBound_internal(srcSize, preferencesPtr, 0); + } return LZ4F_compressBound_internal(srcSize, preferencesPtr, (size_t)-1); } diff --git a/lib/lz4frame.h b/lib/lz4frame.h index 391e484..87b0b2a 100644 --- a/lib/lz4frame.h +++ b/lib/lz4frame.h @@ -284,7 +284,7 @@ LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx* cctx, * @return is always the same for a srcSize and prefsPtr. * prefsPtr is optional : when NULL is provided, preferences will be set to cover worst case scenario. * tech details : - * @return includes the possibility that internal buffer might already be filled by up to (blockSize-1) bytes. + * @return if automatic flushing is not enabled, includes the possibility that internal buffer might already be filled by up to (blockSize-1) bytes. * It also includes frame footer (ending + checksum), since it might be generated by LZ4F_compressEnd(). * @return doesn't include frame header, as it was already generated by LZ4F_compressBegin(). */ -- cgit v0.12