]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: ensure DnsStream.fd is initialized before first error path
authorLennart Poettering <lennart@poettering.net>
Tue, 4 Dec 2018 18:14:28 +0000 (19:14 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Dec 2018 16:16:29 +0000 (17:16 +0100)
src/resolve/resolved-dns-stream.c

index 8964a8636aa491210f70261b5f58e1bc936125d7..5aefb94407ebf0c211b1f73d698766caf82ec2bf 100644 (file)
@@ -465,18 +465,20 @@ int dns_stream_new(Manager *m, DnsStream **ret, DnsProtocol protocol, int fd, co
         if (m->n_dns_streams > DNS_STREAMS_MAX)
                 return -EBUSY;
 
-        s = new0(DnsStream, 1);
+        s = new(DnsStream, 1);
         if (!s)
                 return -ENOMEM;
 
+        *s = (DnsStream) {
+                .n_ref = 1,
+                .fd = -1,
+                .protocol = protocol,
+        };
+
         r = ordered_set_ensure_allocated(&s->write_queue, &dns_packet_hash_ops);
         if (r < 0)
                 return r;
 
-        s->n_ref = 1;
-        s->fd = -1;
-        s->protocol = protocol;
-
         r = sd_event_add_io(m->event, &s->io_event_source, fd, EPOLLIN, on_stream_io, s);
         if (r < 0)
                 return r;