Browse Source

resolv: fix memory leak

Timothy Holdener writes:
small memory leak in __dns_lookup() when the A record
in the DNS answer is preceded by one or more CNAME records.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer 12 years ago
parent
commit
bb8d500a75
1 changed files with 2 additions and 0 deletions
  1. 2 0
      libc/inet/resolv.c

+ 2 - 0
libc/inet/resolv.c

@@ -1507,6 +1507,7 @@ int attribute_hidden __dns_lookup(const char *name,
 		DPRINTF("Decoding answer at pos %d\n", pos);
 
 		first_answer = 1;
+		a->dotted = NULL;
 		for (j = 0; j < h.ancount; j++) {
 			i = __decode_answer(packet, pos, packet_len, &ma);
 			if (i < 0) {
@@ -1523,6 +1524,7 @@ int attribute_hidden __dns_lookup(const char *name,
 				ma.buf = a->buf;
 				ma.buflen = a->buflen;
 				ma.add_count = a->add_count;
+				free(a->dotted);
 				memcpy(a, &ma, sizeof(ma));
 				if (a->atype != T_SIG && (NULL == a->buf || (type != T_A && type != T_AAAA)))
 					break;