[PATCH] workspaces: don't segfault on invalid move_surface_to_workspace request

Kristian Høgsberg hoegsberg at gmail.com
Tue Sep 4 13:18:40 PDT 2012


On Sat, Sep 01, 2012 at 04:03:05PM +0200, Philipp Brüschweiler wrote:
> Also fixes the off-by-one in toytoolkit that exposed the issue.

Thanks, applied.

> ---
>  clients/window.c | 2 +-
>  src/shell.c      | 4 ++++
>  2 Dateien geändert, 5 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index 472aabf..4ddbd2f 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -1704,7 +1704,7 @@ frame_menu_func(struct window *window, int index, void *data)
>  		break;
>  	case 3: /* move to workspace below */
>  		display = window->display;
> -		if (display->workspace < display->workspace_count)
> +		if (display->workspace < display->workspace_count - 1)
>  			workspace_manager_move_surface(display->workspace_manager,
>  						       window->surface,
>  						       display->workspace + 1);
> diff --git a/src/shell.c b/src/shell.c
> index 6610927..06d8684 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -548,6 +548,7 @@ static struct workspace *
>  get_workspace(struct desktop_shell *shell, unsigned int index)
>  {
>  	struct workspace **pws = shell->workspaces.array.data;
> +	assert(index < shell->workspaces.num);
>  	pws += index;
>  	return *pws;
>  }
> @@ -849,6 +850,9 @@ move_surface_to_workspace(struct desktop_shell *shell,
>  	if (workspace == shell->workspaces.current)
>  		return;
>  
> +	if (workspace >= shell->workspaces.num)
> +		workspace = shell->workspaces.num - 1;
> +
>  	from = get_current_workspace(shell);
>  	to = get_workspace(shell, workspace);
>  
> -- 
> 1.7.12
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list