wayland: don't try to use a non-existing viewporter interface

When instantiating the viewport for a pointer surface, we didn't first
check if the compositor implements the viewporter interface.

This triggered a crash when a) foot was compiled with fractional
scaling, and b) the compositor did not implement the viewporter
interface.

Closes #1444
This commit is contained in:
Daniel Eklöf 2023-07-28 15:32:42 +02:00
parent 139fd6d55c
commit 9d75c55146
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 17 additions and 10 deletions

View file

@ -69,10 +69,13 @@
* Regression: line- and box drawing characters not covering the full
height of the line, when a custom `line-height` is being used
([#1430][1430]).
* Crash when compositor does not implement the _viewporter_ interface
([#1444][1444]).
[1423]: https://codeberg.org/dnkl/foot/issues/1423
[1431]: https://codeberg.org/dnkl/foot/issues/1431
[1430]: https://codeberg.org/dnkl/foot/issues/1430
[1444]: https://codeberg.org/dnkl/foot/issues/1444
### Security

View file

@ -315,15 +315,17 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
}
#if defined(HAVE_FRACTIONAL_SCALE)
xassert(seat->pointer.surface.viewport == NULL);
seat->pointer.surface.viewport = wp_viewporter_get_viewport(
seat->wayl->viewporter, seat->pointer.surface.surf);
if (seat->wayl->viewporter != NULL) {
xassert(seat->pointer.surface.viewport == NULL);
seat->pointer.surface.viewport = wp_viewporter_get_viewport(
seat->wayl->viewporter, seat->pointer.surface.surf);
if (seat->pointer.surface.viewport == NULL) {
LOG_ERR("%s: failed to create pointer viewport", seat->name);
wl_surface_destroy(seat->pointer.surface.surf);
seat->pointer.surface.surf = NULL;
return;
if (seat->pointer.surface.viewport == NULL) {
LOG_ERR("%s: failed to create pointer viewport", seat->name);
wl_surface_destroy(seat->pointer.surface.surf);
seat->pointer.surface.surf = NULL;
return;
}
}
#endif
@ -351,8 +353,10 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
wl_surface_destroy(seat->pointer.surface.surf);
#if defined(HAVE_FRACTIONAL_SCALE)
wp_viewport_destroy(seat->pointer.surface.viewport);
seat->pointer.surface.viewport = NULL;
if (seat->pointer.surface.viewport != NULL) {
wp_viewport_destroy(seat->pointer.surface.viewport);
seat->pointer.surface.viewport = NULL;
}
#endif
if (seat->pointer.theme != NULL)