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

Kristian Hoegsberg hoegsberg at gmail.com
Thu Mar 8 10:09:45 PST 2012


On Mon, Mar 05, 2012 at 02:13:13PM +0800, zhiwen.wu at linux.intel.com wrote:
> 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.

Thanks.  I applied it but edited is slightly to just return early if
focus is NULL.

Kristian

> ---
>  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