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:
emersion 2018-01-30 19:45:57 +01:00
parent 704130cc11
commit babdd6ccf7
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
10 changed files with 27 additions and 13 deletions

View file

@ -62,8 +62,6 @@ static bool output_swap_buffers(struct wlr_output *wlr_output) {
static void output_destroy(struct wlr_output *wlr_output) {
struct wlr_headless_output *output =
(struct wlr_headless_output *)wlr_output;
wl_signal_emit(&output->backend->backend.events.output_remove,
&output->wlr_output);
wl_list_remove(&output->link);