Skip to content

seat: fix NULL deref in handle_seat_node_destroy - #9246

Open
matheusc457 wants to merge 2 commits into
swaywm:masterfrom
matheusc457:fix/seat-null-focus-crash
Open

seat: fix NULL deref in handle_seat_node_destroy#9246
matheusc457 wants to merge 2 commits into
swaywm:masterfrom
matheusc457:fix/seat-null-focus-crash

Conversation

@matheusc457

Copy link
Copy Markdown
Contributor

seat_get_focus_inactive(seat, &root->node) can return NULL when the seat's focus_stack is empty (e.g. a secondary seat that never received real focus, in a multi-seat setup, once the last tracked container/workspace in its focus_stack is destroyed).

The focus_inactive branch of handle_seat_node_destroy dereferenced that return value unconditionally
(focus->type), causing an immediate crash of the whole compositor in that state.

This guards the dereference with a NULL check, matching the safe usage pattern already used elsewhere in the codebase (workspace_consider_destroy compares the return value with == instead of dereferencing it directly).

seat_get_focus_inactive(seat, &root->node) can return NULL when
the seat's focus_stack is empty (e.g. a secondary seat that never
received real focus, in a multi-seat setup, once the last tracked
container/workspace in its focus_stack is destroyed).

The focus_inactive branch of handle_seat_node_destroy
dereferenced that return value unconditionally
(focus->type), causing an immediate crash of the whole
compositor in that state.

This guards the dereference with a NULL check, matching
the safe usage pattern already used elsewhere in the
codebase (workspace_consider_destroy compares the return
value with == instead of dereferencing it directly).

@WhyNotHugo WhyNotHugo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, description and implementation are both sound.

Comment thread sway/input/seat.c Outdated
Avoids the extra indentation level, as suggested by WhyNotHugo in review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants