diff --git a/usr.sbin/pkg/dns_utils.c b/usr.sbin/pkg/dns_utils.c index e88bf989d821..239be90c9b02 100644 --- a/usr.sbin/pkg/dns_utils.c +++ b/usr.sbin/pkg/dns_utils.c @@ -66,10 +66,9 @@ dns_getsrvinfo(const char *zone) p += len + NS_QFIXEDSZ; } - res = malloc(sizeof(struct dns_srvinfo) * ancount); + res = calloc(ancount, sizeof(struct dns_srvinfo)); if (res == NULL) return (NULL); - memset(res, 0, sizeof(struct dns_srvinfo) * ancount); n = 0; while (ancount > 0 && p < end) {