From: Lennart Poettering Date: Tue, 4 Dec 2018 21:13:39 +0000 (+0100) Subject: resolved: pin stream while calling callbacks for it X-Git-Tag: v240~111^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d973d94dec349fb676fdd844f6fe2ada3538f27c;p=thirdparty%2Fsystemd.git resolved: pin stream while calling callbacks for it These callbacks might unref the stream, but we still have to access it, let's hence ref it explicitly. Maybe fixes: #10725 --- diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c index d35c875e473..deb5abac5be 100644 --- a/src/resolve/resolved-dns-stream.c +++ b/src/resolve/resolved-dns-stream.c @@ -46,6 +46,8 @@ static int dns_stream_update_io(DnsStream *s) { } static int dns_stream_complete(DnsStream *s, int error) { + _cleanup_(dns_stream_unrefp) _unused_ DnsStream *ref = dns_stream_ref(s); /* Protect stream while we process it */ + assert(s); #if ENABLE_DNS_OVER_TLS @@ -273,7 +275,7 @@ static int on_stream_timeout(sd_event_source *es, usec_t usec, void *userdata) { } static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *userdata) { - DnsStream *s = userdata; + _cleanup_(dns_stream_unrefp) DnsStream *s = dns_stream_ref(userdata); /* Protect stream while we process it */ int r; assert(s);