mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
backend: fix use-after-free when destroying backends
The backend destroy signal is emitted before the output_remove signal is. When the destroy signal is emitted listeners remove their output_remove listener, so the output_remove signal is never received and listeners have an invalid output pointer. The correct way to solve this would be to remove the output_remove signal completely and use the wlr_output.events.destroy signal instead. This isn't yet possible because wl_signal_emit is unsafe and listeners cannot be removed in listeners.
This commit is contained in:
parent
704130cc11
commit
babdd6ccf7
10 changed files with 27 additions and 13 deletions
|
|
@ -42,11 +42,16 @@ static void subbackend_state_destroy(struct subbackend_state *sub) {
|
|||
|
||||
static void multi_backend_destroy(struct wlr_backend *wlr_backend) {
|
||||
struct wlr_multi_backend *backend = (struct wlr_multi_backend *)wlr_backend;
|
||||
|
||||
wl_list_remove(&backend->display_destroy.link);
|
||||
|
||||
struct subbackend_state *sub, *next;
|
||||
wl_list_for_each_safe(sub, next, &backend->backends, link) {
|
||||
wlr_backend_destroy(sub->backend);
|
||||
}
|
||||
|
||||
// Destroy this backend only after removing all sub-backends
|
||||
wl_signal_emit(&wlr_backend->events.destroy, backend);
|
||||
free(backend);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue