ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
7eab74
From 5b9f33c30309345738eedc226f6a667968949044 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
7eab74
index 7f47e7223a..f5faf154f2 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);
7eab74
-- 
7eab74
2.37.1
7eab74