restored nullifying output
authorYann Collet <cyan@fb.com>
Mon, 10 Sep 2018 23:22:16 +0000 (16:22 -0700)
committerYann Collet <cyan@fb.com>
Mon, 10 Sep 2018 23:22:16 +0000 (16:22 -0700)
to counter possible (offset==0)

lib/lz4.c

index c68a7da..0545bbc 100644 (file)
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1536,7 +1536,11 @@ LZ4_decompress_generic(
 
 _copy_match:
         if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) goto _output_error;   /* Error : offset outside buffers */
-        // LZ4_write32(op, (U32)offset);   /* costs ~1%; silence an msan warning when offset==0 */   /* note : no longer valid with partialDecoding, since there is no guarantee that at least 4 bytes are available */
+        if (!partialDecoding) {
+            assert(oend > op);
+            assert(oend - op >= 4);
+            LZ4_write32(op, 0);   /* silence an msan warning when offset==0; costs <1%; */
+        }   /* note : when partialDecoding, there is no guarantee that at least 4 bytes remain available in output buffer */
 
         if (length == ML_MASK) {
             unsigned s;