diff options
author | Isaac Freund <ifreund@ifreund.xyz> | 2020-12-13 16:07:31 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-12-22 15:55:05 +0100 |
commit | f6fc4c28830dd2391d7e61f7cec0c4d2d89d1f07 (patch) | |
tree | 421bbeaddc9cae24581b7de3a6db82650ac152a0 | |
parent | ad4dae08443dbbe1609b215f9bf375024d32f43c (diff) |
subsurface: handle NULL parent in get_root_surface
-rw-r--r-- | include/wlr/types/wlr_surface.h | 3 | ||||
-rw-r--r-- | types/wlr_surface.c | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index abb05600..175150f9 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -220,7 +220,8 @@ struct wlr_subsurface *wlr_subsurface_create(struct wlr_surface *surface, struct wl_list *resource_list); /** - * Get the root of the subsurface tree for this surface. + * Get the root of the subsurface tree for this surface. Can return NULL if + * a surface in the tree has been destroyed. */ struct wlr_surface *wlr_surface_get_root_surface(struct wlr_surface *surface); diff --git a/types/wlr_surface.c b/types/wlr_surface.c index c251816e..dd022489 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -1061,6 +1061,9 @@ struct wlr_surface *wlr_surface_get_root_surface(struct wlr_surface *surface) { if (subsurface == NULL) { break; } + if (subsurface->parent == NULL) { + return NULL; + } surface = subsurface->parent; } return surface; |