resolve: first increment the reference counter

When `exist->rr` and `rr` point to the same object, then it may be freed by
the `dns_resource_record_unref()`.
This commit is contained in:
Yu Watanabe
2022-05-07 15:14:41 +09:00
parent 6edf21dba7
commit 4ce30e4de0
+2 -1
View File
@@ -169,8 +169,9 @@ int dns_answer_add(
/* Entry already exists, keep the entry with the higher TTL. */
if (rr->ttl > exist->rr->ttl) {
dns_resource_record_ref(rr);
dns_resource_record_unref(exist->rr);
exist->rr = dns_resource_record_ref(rr); /* lgtm [cpp/inconsistent-null-check] */
exist->rr = rr;
/* Update RRSIG and RR at the same time */
if (rrsig) {