[PATCH] shell: Fix segment fault when clicking to activate a NULL pointer_focus

zhiwen.wu at linux.intel.com zhiwen.wu at linux.intel.com
Sun Mar 4 22:13:13 PST 2012


From: Alex Wu <zhiwen.wu at linux.intel.com>

This can happen for instance running a toytoolkit application, launching
the popup menu and then clicking on a surface that does not belong to
the client that create the popup surface.
---
 src/shell.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index ac7301a..86edaf6 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1414,12 +1414,15 @@ click_to_activate_binding(struct wl_input_device *device,
 	struct weston_surface *upper;
 
 	focus = (struct weston_surface *) device->pointer_focus;
-	upper = container_of(focus->link.prev, struct weston_surface, link);
-	if (focus->link.prev != &compositor->surface_list &&
-	    get_shell_surface_type(upper) == SHELL_SURFACE_FULLSCREEN) {
-		printf("%s: focus is black surface, raise its fullscreen surface\n", __func__);
-		shell_stack_fullscreen(get_shell_surface(upper));
-		focus = upper;
+
+	if (focus) {
+		upper = container_of(focus->link.prev, struct weston_surface, link);
+		if (focus->link.prev != &compositor->surface_list &&
+		    get_shell_surface_type(upper) == SHELL_SURFACE_FULLSCREEN) {
+			printf("%s: focus is black surface, raise its fullscreen surface\n", __func__);
+			shell_stack_fullscreen(get_shell_surface(upper));
+			focus = upper;
+		}
 	}
 
 	if (state && focus && device->pointer_grab == &device->default_pointer_grab)
-- 
1.7.5.4



More information about the wayland-devel mailing list