fix #874
authorYann Collet <cyan@fb.com>
Sun, 8 Nov 2020 21:21:58 +0000 (13:21 -0800)
committerYann Collet <cyan@fb.com>
Sun, 8 Nov 2020 21:21:58 +0000 (13:21 -0800)
coverity reported a warning regarding a memcpy() overwrite.
This is a false positive (the memory area is large enough),
but it's true that it's not trivial to determine (encompassing struct),
and it's proper anyway to only memcpy() just the right amount of data.

lib/lz4.c

index 427673eb4ec5513f88ab6a43442d8edaed75072b..aca97ed9c046b046f91324796db4ed4a43fdfb8c 100644 (file)
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1606,7 +1606,7 @@ int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream,
                  * cost to copy the dictionary's tables into the active context,
                  * so that the compression loop is only looking into one table.
                  */
-                LZ4_memcpy(streamPtr, streamPtr->dictCtx, sizeof(LZ4_stream_t));
+                LZ4_memcpy(streamPtr, streamPtr->dictCtx, sizeof(*streamPtr));
                 result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingExtDict, noDictIssue, acceleration);
             } else {
                 result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingDictCtx, noDictIssue, acceleration);