]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-event: take ref on event loop object before dispatching event sources
authorMichal Sekletar <msekleta@redhat.com>
Wed, 8 Sep 2021 13:42:11 +0000 (15:42 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Sep 2021 16:15:57 +0000 (01:15 +0900)
Idea is that all public APIs should take reference on objects that get
exposed to user-provided callbacks. We take the reference as a
protection from callbacks dropping it. We used to do this also here in
sd_event_loop(). However, in cleanup portion of f814c871e6 this was
accidentally dropped.

src/libsystemd/sd-event/sd-event.c

index cb8f54b1d522b03c83fdb2f3e9875f94ba0d0e65..b06e00fae27c0f0cdd2021239077bb329a245582 100644 (file)
@@ -4154,7 +4154,7 @@ _public_ int sd_event_loop(sd_event *e) {
         assert_return(!event_pid_changed(e), -ECHILD);
         assert_return(e->state == SD_EVENT_INITIAL, -EBUSY);
 
-        _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = NULL;
+        _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = sd_event_ref(e);
 
         while (e->state != SD_EVENT_FINISHED) {
                 r = sd_event_run(e, UINT64_MAX);