ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
626085
From 420ffdb2b6c0d445b2f911cddfbee0a0d94c013d Mon Sep 17 00:00:00 2001
7eab74
From: Lennart Poettering <lennart@poettering.net>
7eab74
Date: Tue, 4 Dec 2018 22:13:39 +0100
7eab74
Subject: [PATCH] resolved: pin stream while calling callbacks for it
7eab74
7eab74
These callbacks might unref the stream, but we still have to access it,
7eab74
let's hence ref it explicitly.
7eab74
7eab74
Maybe fixes: #10725
7eab74
7eab74
(cherry picked from commit d973d94dec349fb676fdd844f6fe2ada3538f27c)
7eab74
7eab74
Resolves: #2110544
7eab74
---
7eab74
 src/resolve/resolved-dns-stream.c | 4 +++-
7eab74
 1 file changed, 3 insertions(+), 1 deletion(-)
7eab74
7eab74
diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c
626085
index 8d898b4819..1068a248ae 100644
7eab74
--- a/src/resolve/resolved-dns-stream.c
7eab74
+++ b/src/resolve/resolved-dns-stream.c
7eab74
@@ -49,6 +49,8 @@ static int dns_stream_update_io(DnsStream *s) {
7eab74
 }
7eab74
 
7eab74
 static int dns_stream_complete(DnsStream *s, int error) {
7eab74
+        _cleanup_(dns_stream_unrefp) _unused_ DnsStream *ref = dns_stream_ref(s); /* Protect stream while we process it */
7eab74
+
7eab74
         assert(s);
7eab74
 
7eab74
         dns_stream_stop(s);
7eab74
@@ -195,7 +197,7 @@ static int on_stream_timeout(sd_event_source *es, usec_t usec, void *userdata) {
7eab74
 }
7eab74
 
7eab74
 static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
7eab74
-        DnsStream *s = userdata;
7eab74
+        _cleanup_(dns_stream_unrefp) DnsStream *s = dns_stream_ref(userdata); /* Protect stream while we process it */
7eab74
         int r;
7eab74
 
7eab74
         assert(s);