Fix segfaults in wlr_surface_is_*

This commit is contained in:
emersion 2018-04-21 19:04:48 +01:00
parent bfcd3f3707
commit 3bce5dfc9f
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
4 changed files with 10 additions and 6 deletions

View File

@ -13,7 +13,8 @@
static const char *wlr_wl_shell_surface_role = "wl-shell-surface";
bool wlr_surface_is_wl_shell_surface(struct wlr_surface *surface) {
return strcmp(surface->role, wlr_wl_shell_surface_role) == 0;
return surface->role != NULL &&
strcmp(surface->role, wlr_wl_shell_surface_role) == 0;
}
struct wlr_wl_surface *wlr_wl_shell_surface_from_wlr_surface(

View File

@ -17,8 +17,9 @@ static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel";
static const char *wlr_desktop_xdg_popup_role = "xdg_popup";
bool wlr_surface_is_xdg_surface(struct wlr_surface *surface) {
return strcmp(surface->role, wlr_desktop_xdg_toplevel_role) == 0 ||
strcmp(surface->role, wlr_desktop_xdg_popup_role) == 0;
return surface->role != NULL &&
(strcmp(surface->role, wlr_desktop_xdg_toplevel_role) == 0 ||
strcmp(surface->role, wlr_desktop_xdg_popup_role) == 0);
}
struct wlr_xdg_surface *wlr_xdg_surface_from_wlr_surface(

View File

@ -17,8 +17,9 @@ static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel_v6";
static const char *wlr_desktop_xdg_popup_role = "xdg_popup_v6";
bool wlr_surface_is_xdg_surface_v6(struct wlr_surface *surface) {
return strcmp(surface->role, wlr_desktop_xdg_toplevel_role) == 0 ||
strcmp(surface->role, wlr_desktop_xdg_popup_role) == 0;
return surface->role != NULL &&
(strcmp(surface->role, wlr_desktop_xdg_toplevel_role) == 0 ||
strcmp(surface->role, wlr_desktop_xdg_popup_role) == 0);
}
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_from_wlr_surface(

View File

@ -80,7 +80,8 @@ const char *atom_map[ATOM_LAST] = {
const char *wlr_xwayland_surface_role = "wlr_xwayland_surface";
bool wlr_surface_is_xwayland_surface(struct wlr_surface *surface) {
return strcmp(surface->role, wlr_xwayland_surface_role) == 0;
return surface->role != NULL &&
strcmp(surface->role, wlr_xwayland_surface_role) == 0;
}
struct wlr_xwayland_surface *wlr_xwayland_surface_from_wlr_surface(