Skip to content

Commit

Permalink
desktop/output: Clear repaint timer earlier in destroy
Browse files Browse the repository at this point in the history
The teardown of a sway_output is split in two: begin_destroy and
output_destroy. The former clears some state such as NULL'ing the
reference to wlr_output, while the latter frees the struct and its
remaining resources.

If an output is destroyed while a repaint timer is pending, future frame
callbacks will no longer occur as the listener is torn down in
begin_destroy, but the repaint timer is not torn down and may still
fire until output_destroy is hit. As begin_destroy cleared the reference
to wlr_output, this leads to a NULL-pointer dereference.

Tear down the repaint timer in begin_destroy as there is no need for it.

Fixes: fdc4318 ("desktop/output: Clear frame_pending even output is disabled")
  • Loading branch information
kennylevinsen authored and Nefsen402 committed Nov 17, 2024
1 parent fec3da7 commit 5312376
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ static void begin_destroy(struct sway_output *output) {
output->wlr_output->data = NULL;
output->wlr_output = NULL;

wl_event_source_remove(output->repaint_timer);
output->repaint_timer = NULL;

request_modeset();
}

Expand Down
1 change: 0 additions & 1 deletion sway/tree/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ void output_destroy(struct sway_output *output) {
destroy_scene_layers(output);
list_free(output->workspaces);
list_free(output->current.workspaces);
wl_event_source_remove(output->repaint_timer);
wlr_color_transform_unref(output->color_transform);
free(output);
}
Expand Down

0 comments on commit 5312376

Please sign in to comment.