From: Lennart Poettering Date: Tue, 4 Dec 2018 18:14:28 +0000 (+0100) Subject: resolved: ensure DnsStream.fd is initialized before first error path X-Git-Tag: v240~111^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=898892e825e7a05891a9f8a5616f041958ef4d61;p=thirdparty%2Fsystemd.git resolved: ensure DnsStream.fd is initialized before first error path --- diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c index 8964a8636aa..5aefb94407e 100644 --- a/src/resolve/resolved-dns-stream.c +++ b/src/resolve/resolved-dns-stream.c @@ -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;