diff options
author | Alexander Mohr <alexander.m.mohr@mercedes-benz.com> | 2022-07-04 06:51:37 (GMT) |
---|---|---|
committer | Alexander Mohr <alexander.m.mohr@mercedes-benz.com> | 2022-07-04 06:51:37 (GMT) |
commit | e595150bafff318f6f66e4b364193b32701449e3 (patch) | |
tree | ccf05c1521f8fd214fd3a71193bcfe5a97f1126c /lib/lz4frame.c | |
parent | 5065080664437efcb4215823b9ad95f5571a9d7c (diff) | |
download | lz4-e595150bafff318f6f66e4b364193b32701449e3.zip lz4-e595150bafff318f6f66e4b364193b32701449e3.tar.gz lz4-e595150bafff318f6f66e4b364193b32701449e3.tar.bz2 |
lz4frame: correct start and size after flush
when the block mode changes a flush is executed, to prevent
mixing compressed and uncompressed data.
Prior to this commit dstStart, dstPtr, dstCapacity
where not updated to include the offset from bytesWritten.
For inputs > blockSize this meant the flushed data was
overwritten.
Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
Diffstat (limited to 'lib/lz4frame.c')
-rw-r--r-- | lib/lz4frame.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c index 251521e..f32ed1d 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -886,7 +886,7 @@ static size_t LZ4F_compressUpdateImpl(LZ4F_cctx* cctxPtr, size_t const blockSize = cctxPtr->maxBlockSize; const BYTE* srcPtr = (const BYTE*)srcBuffer; const BYTE* const srcEnd = srcPtr + srcSize; - BYTE* const dstStart = (BYTE*)dstBuffer; + BYTE* dstStart = (BYTE*)dstBuffer; BYTE* dstPtr = dstStart; LZ4F_lastBlockStatus lastBlockCompressed = notDone; compressFunc_t const compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel); @@ -896,6 +896,9 @@ static size_t LZ4F_compressUpdateImpl(LZ4F_cctx* cctxPtr, /* flush currently written block, to continue with new block compression */ if (cctxPtr->blockCompression != blockCompression) { bytesWritten = LZ4F_flush(cctxPtr, dstBuffer, dstCapacity, compressOptionsPtr); + dstStart = (BYTE*)dstBuffer + bytesWritten; + dstPtr = dstStart; + dstCapacity -= bytesWritten; cctxPtr->blockCompression = blockCompression; } |