Free the old version of the keyname (if it exists) before setting
the new one.
if (i < ipkl->count) { /* we have this record already */
if (value->type == dns_rdatatype_txt) {
+ if (ipkl->keys[i] != NULL) {
+ if (dns_name_dynamic(ipkl->keys[i])) {
+ dns_name_free(ipkl->keys[i],
+ mctx);
+ }
+ isc_mem_put(mctx, ipkl->keys[i],
+ sizeof(*ipkl->keys[i]));
+ }
ipkl->keys[i] = keyname;
} else { /* A/AAAA */
memmove(&ipkl->addrs[i], &sockaddr,