X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b0d623f7f2ae71ed96e60569f61f9a9a27016e80..7e41aa883dd258f888d0470250eead40a53ef1f5:/libkern/zlib/zutil.c?ds=sidebyside diff --git a/libkern/zlib/zutil.c b/libkern/zlib/zutil.c index 020291bc1..f90ac37a7 100644 --- a/libkern/zlib/zutil.c +++ b/libkern/zlib/zutil.c @@ -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)