From: Felix Fietkau Date: Tue, 3 Jun 2014 21:23:12 +0000 (+0200) Subject: dns: use alloca instead of malloc to fix memleak in dns_send_answer() X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fmdnsd.git;a=commitdiff_plain;h=85ac2adb78d343c0bf75e055380afa557816546e dns: use alloca instead of malloc to fix memleak in dns_send_answer() Signed-off-by: Felix Fietkau --- diff --git a/dns.c b/dns.c index 517825b..cf8c3d5 100644 --- a/dns.c +++ b/dns.c @@ -182,10 +182,7 @@ dns_send_answer(struct uloop_fd *u, char *answer) h.answers = __cpu_to_be16(dns_answer_cnt); h.flags = __cpu_to_be16(0x8400); - iov = malloc(sizeof(struct iovec) * ((dns_answer_cnt * 3) + 1)); - if (!iov) - return; - + iov = alloca(sizeof(struct iovec) * ((dns_answer_cnt * 3) + 1)); iov[0].iov_base = &h; iov[0].iov_len = sizeof(struct dns_header);