]> granicus.if.org Git - xz/commitdiff
liblzma: Silence harmless Valgrind errors.
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 26 Jan 2015 18:39:28 +0000 (20:39 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 26 Jan 2015 18:39:28 +0000 (20:39 +0200)
Thanks to Torsten Rupp for reporting this. I had
forgotten to run Valgrind before the 5.2.0 release.

src/liblzma/lz/lz_encoder.c

index 2033844f5d358af05723caac3bd0a3613cab2d02..01dfc06f3eca7acbb83d14ffcc0306147b9e8300 100644 (file)
@@ -110,6 +110,12 @@ fill_window(lzma_coder *coder, const lzma_allocator *allocator,
 
        coder->mf.write_pos = write_pos;
 
+       // Silence Valgrind. lzma_memcmplen() can read extra bytes
+       // and Valgrind will give warnings if those bytes are uninitialized
+       // because Valgrind cannot see that the values of the uninitialized
+       // bytes are eventually ignored.
+       memzero(coder->mf.buffer + write_pos, LZMA_MEMCMPLEN_EXTRA);
+
        // If end of stream has been reached or flushing completed, we allow
        // the encoder to process all the input (that is, read_pos is allowed
        // to reach write_pos). Otherwise we keep keep_size_after bytes