From: Nathan Moinvaziri Date: Sun, 28 Jun 2020 21:45:22 +0000 (-0700) Subject: Use calloc to allocate memory and set to zero for memory sanitizer. X-Git-Tag: 1.9.9-b1~166 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=551254a4c175fbebfabffaa9a4684ab528f10c89;p=thirdparty%2Fzlib-ng.git Use calloc to allocate memory and set to zero for memory sanitizer. --- diff --git a/test/minigzip.c b/test/minigzip.c index df260967..a09fcdcc 100644 --- a/test/minigzip.c +++ b/test/minigzip.c @@ -90,7 +90,7 @@ void error(const char *msg) { */ void gz_compress(FILE *in, gzFile out) { - char *buf = (char *)malloc(BUFLEN); + char *buf = (char *)calloc(BUFLEN, 1); int len; int err; @@ -100,9 +100,6 @@ 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, BUFLEN); for (;;) { len = (int)fread(buf, 1, BUFLEN, in); if (ferror(in)) {