From 03b0f4c2aa35548e0655db002b21e1e02dd8210e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Mon, 13 Mar 2023 15:24:18 +0100 Subject: [PATCH] fbd-event: Make sure we iterate the list safely When all feedbacks are done the event signals "feedbacks-ended" which lets the manager dispose the feedback. When all feedbacks end instantly and synchronously (as is the case with the dummy feedback) this triggers the disposal of the event within the loop leading to a crash. Make sure the object doesn't go away be referencing it during the loop iteration. We didn't see this before as glib's slice allocator for lists papered over this for us. Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/69 --- src/fbd-event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fbd-event.c b/src/fbd-event.c index 5791d2f..917b5e2 100644 --- a/src/fbd-event.c +++ b/src/fbd-event.c @@ -390,10 +390,12 @@ fbd_event_run_feedbacks (FbdEvent *self) g_source_set_name_by_id (self->timeout_id, "event timeout source"); } + g_object_ref (self); for (GSList *l = self->feedbacks; l; l = l->next) { FbdFeedbackBase *fb = FBD_FEEDBACK_BASE (l->data); fbd_feedback_run (fb); } + g_object_unref (self); } /**