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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user