[PATCH weston] SIGSEGV in window.c

Paul Winwood paul.winwood at hotmail.co.uk
Tue Aug 27 14:13:09 PDT 2013


Please go easy with me; this is the first time I have ever done this!
I have found and fixed a SIGSEGV in window.c in pointer_handle_motion  caused by dereferencing 'window' when it is null.
There was a null pointer check after the dereference. The fix is to move the check before it.
Patch:
--- weston/clients/window.c.orig	2013-08-27 20:43:00.000000000 +0100
+++ weston/clients/window.c	2013-08-27 21:56:27.271755837 +0100
@@ -2904,6 +2904,9 @@ pointer_handle_motion(void *data, struct
 	float sx = wl_fixed_to_double(sx_w);
 	float sy = wl_fixed_to_double(sy_w);
 
+	if (!window)
+	  return;
+	  
 	/* when making the window smaller - e.g. after a unmaximise we might
 	 * still have a pending motion event that the compositor has picked
 	 * based on the old surface dimensions
@@ -2915,9 +2918,6 @@ pointer_handle_motion(void *data, struct
 	input->sx = sx;
 	input->sy = sy;
 
-	if (!window)
-		return;
-
 	if (!(input->grab && input->grab_button)) {
 		widget = window_find_widget(window, sx, sy);
 		input_set_focus_widget(input, widget, sx, sy);

Is this OK?
Thanks,
Paul.


More information about the wayland-devel mailing list