1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-09 12:58:26 +03:00

resolved-dns-rr: use automatic cleanup

Follow-up for #27770.
This commit is contained in:
David Tardon 2023-05-25 10:30:06 +02:00 committed by Mike Yuan
parent 9c9b9b8915
commit 19038903e1

View File

@ -1197,7 +1197,7 @@ ssize_t dns_resource_record_payload(DnsResourceRecord *rr, void **out) {
int dns_resource_record_to_wire_format(DnsResourceRecord *rr, bool canonical) {
DnsPacket packet = {
_cleanup_(dns_packet_unref) DnsPacket packet = {
.n_ref = 1,
.protocol = DNS_PROTOCOL_DNS,
.on_stack = true,
@ -1222,10 +1222,8 @@ int dns_resource_record_to_wire_format(DnsResourceRecord *rr, bool canonical) {
return 0;
r = dns_packet_append_rr(&packet, rr, 0, &start, &rds);
if (r < 0) {
dns_packet_unref(&packet);
if (r < 0)
return r;
}
assert(start == 0);
assert(packet._data);
@ -1236,8 +1234,6 @@ int dns_resource_record_to_wire_format(DnsResourceRecord *rr, bool canonical) {
rr->wire_format_rdata_offset = rds;
rr->wire_format_canonical = canonical;
dns_packet_unref(&packet);
return 0;
}