diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2015-11-04 23:14:00 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2016-06-28 21:09:46 +0300 |
commit | 8173ff8790ad3502d04e1c07d014cb84a3b8187b (patch) | |
tree | bf45f54b730ab98b116f09aac0d2158e1f78ab0a | |
parent | liblzma: Rename lzma_presets.c back to lzma_encoder_presets.c. (diff) | |
download | xz-8173ff8790ad3502d04e1c07d014cb84a3b8187b.tar.xz |
liblzma: Make Valgrind happier with optimized (gcc -O2) liblzma.
When optimizing, GCC can reorder code so that an uninitialized
value gets used in a comparison, which makes Valgrind unhappy.
It doesn't happen when compiled with -O0, which I tend to use
when running Valgrind.
Thanks to Rich Prohaska. I remember this being mentioned long
ago by someone else but nothing was done back then.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/lz/lz_encoder.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/liblzma/lz/lz_encoder.c b/src/liblzma/lz/lz_encoder.c index 48bc487d..5a2be798 100644 --- a/src/liblzma/lz/lz_encoder.c +++ b/src/liblzma/lz/lz_encoder.c @@ -541,7 +541,11 @@ lzma_lz_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, next->coder->lz.code = NULL; next->coder->lz.end = NULL; + // mf.size is initialized to silence Valgrind + // when used on optimized binaries (GCC may reorder + // code in a way that Valgrind gets unhappy). next->coder->mf.buffer = NULL; + next->coder->mf.size = 0; next->coder->mf.hash = NULL; next->coder->mf.son = NULL; next->coder->mf.hash_count = 0; |