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
This commit is contained in:
Guido Günther
2023-03-13 15:25:41 +01:00
parent 64076e5ad0
commit 03b0f4c2aa
+2
View File
@@ -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);
}
/**