[PATCH weston] Don't segfault clients when cursor isn't found

Daniel Stone daniel at fooishbar.org
Mon Jun 18 11:31:12 PDT 2012


If we can't find a cursor for whatever reason, don't crash the client in
pointer_surface_frame_callback.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 clients/window.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 436f862..36caeb3 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2312,8 +2312,7 @@ pointer_surface_frame_callback(void *data, struct wl_callback *callback,
 			       uint32_t time)
 {
 	struct input *input = data;
-	struct wl_cursor *cursor =
-		input->display->cursors[input->current_cursor];
+	struct wl_cursor *cursor;
 	int i;
 
 	if (callback) {
@@ -2324,6 +2323,9 @@ pointer_surface_frame_callback(void *data, struct wl_callback *callback,
 
 	if (input->current_cursor == CURSOR_UNSET)
 		return;
+	cursor = input->display->cursors[input->current_cursor];
+	if (!cursor)
+		return;
 
 	/* FIXME We don't have the current time on the first call so we set
 	 * the animation start to the time of the first frame callback. */
-- 
1.7.10



More information about the wayland-devel mailing list