[virt-tools-list] [PATCH virt-viewer v5 2/3] session-spice: Set fullscreen displays according to monitor-mapping

Pavel Grunt pgrunt at redhat.com
Wed May 6 08:58:18 UTC 2015


On Tue, 2015-05-05 at 13:48 +0200, Pavel Grunt wrote:
> It is necessary to follow the monitor mapping, otherwise a display
> can get dimensions which belongs to other than desired monitor.
> 
> Related: rhbz#1212802
> ---
> v5: - prevented the potential illegal array access 
> (displays[GPOINTER_TO_INT(l->data)])
> ---
>  src/virt-viewer-session-spice.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer
> -session-spice.c
> index b69faa6..cdba054 100644
> --- a/src/virt-viewer-session-spice.c
> +++ b/src/virt-viewer-session-spice.c
> @@ -866,12 +866,13 @@ 
> virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice 
> *self)
>      displays = g_new0(GdkRectangle, ndisplays);
>  
>      for (i = 0, l = initial_displays; l != NULL; l = l->next, i++) {
and 'i' can be removed from the for cycle
> -        GdkRectangle* rect = &displays[i];
> -        gint j = 
> virt_viewer_app_get_initial_monitor_for_display(app, 
> GPOINTER_TO_INT(l->data));
> -        if (j == -1)
> +        gint display_id = GPOINTER_TO_INT(l->data);
> +        gint j = 
> virt_viewer_app_get_initial_monitor_for_display(app, display_id);
> +        g_warn_if_fail(display_id < ndisplays);
> +        if (j == -1 || display_id >= ndisplays)
>              continue;
>  
> -        gdk_screen_get_monitor_geometry(screen, j, rect);
> +        gdk_screen_get_monitor_geometry(screen, j, 
> &displays[display_id]);
>      }
>      g_list_free(initial_displays);
>  




More information about the virt-tools-list mailing list