summaryrefslogtreecommitdiff
path: root/Utilities/cmzlib
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-05-26 11:00:52 -0400
committerBrad King <brad.king@kitware.com>2022-05-26 12:29:41 -0400
commit0d201ad25ba4ddf83b4f17986ff5fd032c9f209e (patch)
tree49abe450b9e14d12de238562d6033398273d7b9b /Utilities/cmzlib
parent512c1f8f75d2536f7db5560fc48d4db8f539c931 (diff)
downloadcmake-0d201ad25ba4ddf83b4f17986ff5fd032c9f209e.tar.gz
zlib: Add initialization to satisfy valgrind
Restore the change from commit cf133ff6b3 (Fix uninitialized variable access in zlib, 2009-11-18, v2.8.2~705). Their web site claims it does no harm ( https://www.zlib.net/zlib_faq.html#faq36), but fixing it this way eliminates the diagnostic.
Diffstat (limited to 'Utilities/cmzlib')
-rw-r--r--Utilities/cmzlib/deflate.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Utilities/cmzlib/deflate.c b/Utilities/cmzlib/deflate.c
index 29ce1f64a5..5ec8374331 100644
--- a/Utilities/cmzlib/deflate.c
+++ b/Utilities/cmzlib/deflate.c
@@ -285,6 +285,13 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
+
+ /* The following memset eliminates the valgrind uninitialized warning
+ "swept under the carpet" here:
+ http://www.zlib.net/zlib_faq.html#faq36 */
+
+ memset(s->window, 0, s->w_size*2*sizeof(Byte));
+
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));