From 1ffa4368cc87f96955f5358b5896156753b59a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Zavan?= <959292+flaviozavan@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:10:43 +0300 Subject: [PATCH] Fix xwayland fullscreen crash (#135) Introduces a trivial fix for a crash in xwayland that could be triggered when a view with NULL size hints tried to go fullscreen --- src/viv_xwayland_shell.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/viv_xwayland_shell.c b/src/viv_xwayland_shell.c index 3832f20..521f28f 100644 --- a/src/viv_xwayland_shell.c +++ b/src/viv_xwayland_shell.c @@ -369,17 +369,20 @@ static void implementation_grow_and_center_fullscreen(struct viv_view *view) { } int width = output->wlr_output->width; - if ((hints->max_width > 0) && ((int) hints->max_width < width)) { - width = hints->max_width; - } else if ((hints->min_width > 0) && ((int) hints->min_width > width)) { - width = hints->min_width; - } - int height = output->wlr_output->height; - if ((hints->max_height > 0) && ((int) hints->max_height < height)) { - height = hints->max_height; - } else if ((hints->min_height > 0) && ((int) hints->min_height > height)) { - height = hints->min_height; + + if (hints) { + if ((hints->max_width > 0) && ((int) hints->max_width < width)) { + width = hints->max_width; + } else if ((hints->min_width > 0) && ((int) hints->min_width > width)) { + width = hints->min_width; + } + + if ((hints->max_height > 0) && ((int) hints->max_height < height)) { + height = hints->max_height; + } else if ((hints->min_height > 0) && ((int) hints->min_height > height)) { + height = hints->min_height; + } } int x = (output->wlr_output->width - width) / 2;