Fix segfault due to use-after-free of wl_seat_listener #2198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I created seat listener object within init function which freed it once the function call was done. As the data was tiny (two bytes), it was very unlikely it'd be overwritten without another tiny heap allocation. They probably ended up on the heap because a pointer to them is passed to
wayland-client
so C++ couldn't stack-allocate them.So the general rule for listeners is that they must be static - I thought Wayland would just copy them as they're trivial and small, but I guess not.
Add some minor additional safety checks to wayland main_loop_wait. These come from kitty code - added them while debugging, but they make the code more robust so I kept them.
Closes #1791