diff options
author | mwenzkowski <29407878+mwenzkowski@users.noreply.github.com> | 2018-12-21 23:25:07 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-28 16:14:35 +0100 |
commit | 7c27d73b02a1958f323a7c30f46c99414cd6f6bf (patch) | |
tree | 44b7f0cd093a14c776ad4781d41cdc36f5e64efd /sway/tree | |
parent | Introduce container_is_scratchpad_hidden (diff) | |
download | sway-7c27d73b02a1958f323a7c30f46c99414cd6f6bf.tar.gz sway-7c27d73b02a1958f323a7c30f46c99414cd6f6bf.tar.zst sway-7c27d73b02a1958f323a7c30f46c99414cd6f6bf.zip |
Check xdg_surface's role before using its toplevel
Don't access xdg_surface->toplevel if xdg_surface->role is equal to
WLR_XDG_SURFACE_ROLE_NONE, since this could lead to crash. The same
checks are added for xdg_surface_v6.
Fixes #3311
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/container.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index e20e44d4..0415d63c 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -341,7 +341,7 @@ static bool surface_is_popup(struct wlr_surface *surface) { | |||
341 | if (wlr_surface_is_xdg_surface(surface)) { | 341 | if (wlr_surface_is_xdg_surface(surface)) { |
342 | struct wlr_xdg_surface *xdg_surface = | 342 | struct wlr_xdg_surface *xdg_surface = |
343 | wlr_xdg_surface_from_wlr_surface(surface); | 343 | wlr_xdg_surface_from_wlr_surface(surface); |
344 | while (xdg_surface) { | 344 | while (xdg_surface && xdg_surface->role != WLR_XDG_SURFACE_ROLE_NONE) { |
345 | if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { | 345 | if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { |
346 | return true; | 346 | return true; |
347 | } | 347 | } |
@@ -353,7 +353,8 @@ static bool surface_is_popup(struct wlr_surface *surface) { | |||
353 | if (wlr_surface_is_xdg_surface_v6(surface)) { | 353 | if (wlr_surface_is_xdg_surface_v6(surface)) { |
354 | struct wlr_xdg_surface_v6 *xdg_surface_v6 = | 354 | struct wlr_xdg_surface_v6 *xdg_surface_v6 = |
355 | wlr_xdg_surface_v6_from_wlr_surface(surface); | 355 | wlr_xdg_surface_v6_from_wlr_surface(surface); |
356 | while (xdg_surface_v6) { | 356 | while (xdg_surface_v6 && |
357 | xdg_surface_v6->role != WLR_XDG_SURFACE_V6_ROLE_NONE) { | ||
357 | if (xdg_surface_v6->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) { | 358 | if (xdg_surface_v6->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) { |
358 | return true; | 359 | return true; |
359 | } | 360 | } |