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:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user