richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
eb17d3
From 814da05c68d9e892c1f89585cc07c6a0330f3e37 Mon Sep 17 00:00:00 2001
eb17d3
From: Michal Sekletar <msekleta@redhat.com>
eb17d3
Date: Wed, 8 Sep 2021 15:42:11 +0200
eb17d3
Subject: [PATCH] sd-event: take ref on event loop object before dispatching
eb17d3
 event sources
eb17d3
eb17d3
Idea is that all public APIs should take reference on objects that get
eb17d3
exposed to user-provided callbacks. We take the reference as a
eb17d3
protection from callbacks dropping it. We used to do this also here in
eb17d3
sd_event_loop(). However, in cleanup portion of f814c871e6 this was
eb17d3
accidentally dropped.
eb17d3
eb17d3
(cherry picked from commit 9f6ef467818f902fe5369c8e37a39a3901bdcf4f)
eb17d3
eb17d3
Resolves: #2024903
eb17d3
---
eb17d3
 src/libsystemd/sd-event/sd-event.c | 2 +-
eb17d3
 1 file changed, 1 insertion(+), 1 deletion(-)
eb17d3
eb17d3
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
eb17d3
index f78da00c3a..47cf93b3f4 100644
eb17d3
--- a/src/libsystemd/sd-event/sd-event.c
eb17d3
+++ b/src/libsystemd/sd-event/sd-event.c
eb17d3
@@ -3838,7 +3838,7 @@ _public_ int sd_event_loop(sd_event *e) {
eb17d3
         assert_return(!event_pid_changed(e), -ECHILD);
eb17d3
         assert_return(e->state == SD_EVENT_INITIAL, -EBUSY);
eb17d3
 
eb17d3
-        _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = NULL;
eb17d3
+        _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = sd_event_ref(e);
eb17d3
 
eb17d3
         while (e->state != SD_EVENT_FINISHED) {
eb17d3
                 r = sd_event_run(e, (uint64_t) -1);