]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use calloc to allocate memory and set to zero for memory sanitizer.
authorNathan Moinvaziri <nathan@nathanm.com>
Sun, 28 Jun 2020 21:45:22 +0000 (14:45 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 29 Jun 2020 09:46:22 +0000 (11:46 +0200)
test/minigzip.c

index df260967eb8d0dfd35a87c138330618616ebbd0e..a09fcdcc24849e4e5e550ae55bb853ce261275e7 100644 (file)
@@ -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)) {