From 551254a4c175fbebfabffaa9a4684ab528f10c89 Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Sun, 28 Jun 2020 14:45:22 -0700 Subject: [PATCH] Use calloc to allocate memory and set to zero for memory sanitizer. --- test/minigzip.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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)) { -- 2.47.2