[PATCH weston] libweston-desktop: don't crash when getting the pid for X clients

Giulio Camuffo giuliocamuffo at gmail.com
Wed Dec 7 11:21:28 UTC 2016


X client's don't have a wl_client associated with their
weston_desktop_client_create, so check that it is valid.

Signed-off-by: Giulio Camuffo <giuliocamuffo at gmail.com>
---
 libweston-desktop/surface.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libweston-desktop/surface.c b/libweston-desktop/surface.c
index 2205107..7ddbaea 100644
--- a/libweston-desktop/surface.c
+++ b/libweston-desktop/surface.c
@@ -588,7 +588,7 @@ weston_desktop_surface_get_app_id(struct weston_desktop_surface *surface)
 WL_EXPORT pid_t
 weston_desktop_surface_get_pid(struct weston_desktop_surface *surface)
 {
-	pid_t pid;
+	pid_t pid = 0;
 
 	if (surface->pid != 0) {
 		pid = surface->pid;
@@ -598,7 +598,8 @@ weston_desktop_surface_get_pid(struct weston_desktop_surface *surface)
 		struct wl_client *wl_client =
 			weston_desktop_client_get_client(client);
 
-		wl_client_get_credentials(wl_client, &pid, NULL, NULL);
+		if (wl_client)
+			wl_client_get_credentials(wl_client, &pid, NULL, NULL);
 	}
 	return pid;
 }
-- 
2.10.2



More information about the wayland-devel mailing list