]> git.saurik.com Git - apple/xnu.git/blobdiff - libkern/zlib/zutil.c
xnu-3248.60.10.tar.gz
[apple/xnu.git] / libkern / zlib / zutil.c
index 020291bc1bad733a66ebb11fb5d005f0356f457e..f90ac37a73baf9bc33ab4647cf23cd4027ec4188 100644 (file)
@@ -331,8 +331,15 @@ voidpf zcalloc (opaque, items, size)
     unsigned size;
 {
     if (opaque) items += size - size; /* make compiler happy */
-    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
-                              (voidpf)calloc(items, size);
+    if (sizeof(uInt) > 2) {
+        /*
+            to prevent use of uninitialized memory, malloc and bzero
+        */
+        voidpf  p = malloc(items * size);
+        bzero(p, items * size); 
+        return p;
+    } else
+        return (voidpf)calloc(items, size);
 }
 
 void  zcfree (opaque, ptr)