From: Sebastian Pop Date: Wed, 15 Aug 2018 19:14:24 +0000 (-0500) Subject: fix bug #184: clear out buf to avoid msan use-of-uninitialized-value X-Git-Tag: 1.9.9-b1~621 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=baddc82378c6fa0d1c18651522fc1cc2662e5c50;p=thirdparty%2Fzlib-ng.git fix bug #184: clear out buf to avoid msan use-of-uninitialized-value Do not use bzero as suggested by Mika Lindqvist: > You shouldn't use bzero() in new code as some compilers, like Visual C++, > don't have it... New code should just use memset(). --- diff --git a/test/minigzip.c b/test/minigzip.c index dc06c35ac..7868c64dd 100644 --- a/test/minigzip.c +++ b/test/minigzip.c @@ -291,6 +291,9 @@ void gz_compress(FILE *in, gzFile out) */ if (gz_compress_mmap(in, out) == Z_OK) return; #endif + /* Clear out the contents of buf before reading from the file to avoid + MemorySanitizer: use-of-uninitialized-value warnings. */ + memset(buf, 0, sizeof(buf)); for (;;) { len = (int)fread(buf, 1, sizeof(buf), in); if (ferror(in)) {