[virt-tools-list] [PATCH virt-viewer] Fix segmentation fault on zoom

Charles Arnold carnold at suse.com
Tue Jun 7 21:03:53 UTC 2016


>>> On 6/7/2016 at 02:38 PM, Fabiano Fidêncio <fidencio at redhat.com> wrote: 
> Charles.
> 
> On Tue, Jun 7, 2016 at 9:51 PM, Charles Arnold <carnold at suse.com> wrote:
>> When virt-viewer is "Waiting for guest domain to start" and
>> the Ctrl- or Ctrl+ keys are pressed to zoom the blank display
>> virt-viewer will crash in virt_viewer_display_get_desktop_size
>> because of a NULL display pointer. To reproduce start virt-viewer
>> on a VM not running and zoom the display.
> 
> Nice catch!
> 
>>
>> Signed-off-by: Charles Arnold <carnold at suse.com>
>>
>> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
>> index ef62d9a..939f5f8 100644
>> --- a/src/virt-viewer-window.c
>> +++ b/src/virt-viewer-window.c
>> @@ -388,6 +388,9 @@ G_MODULE_EXPORT void
>>  virt_viewer_window_menu_view_zoom_out(GtkWidget *menu G_GNUC_UNUSED,
>>                                        VirtViewerWindow *self)
>>  {
>> +    if ( self->priv->display == NULL )
>> +        return;
>> +
>>      virt_viewer_window_set_zoom_level(self,
>>                                        
> virt_viewer_window_get_real_zoom_level(self) - ZOOM_STEP);
>>  }
>> @@ -396,6 +399,9 @@ G_MODULE_EXPORT void
>>  virt_viewer_window_menu_view_zoom_in(GtkWidget *menu G_GNUC_UNUSED,
>>                                       VirtViewerWindow *self)
>>  {
>> +    if ( self->priv->display == NULL )
>> +        return;
>> +
>>      virt_viewer_window_set_zoom_level(self,
>>                                        
> virt_viewer_window_get_real_zoom_level(self) + ZOOM_STEP);
>>  }
>>
>>
>>
>> _______________________________________________
>> virt-tools-list mailing list
>> virt-tools-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list
> 
> I'd prefer to have the check done on
> virt_viewer_window_get_real_zoom_level(), like the example below. What
> do you think? If you agree I'll do the change before pushing and keep
> your ownership of the patch.

No problem. That will also work.

- Charles

> 
> [ffidenci at cat virt-viewer]$ git diff
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index ef62d9a..38effab 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -378,6 +378,9 @@
> virt_viewer_window_get_real_zoom_level(VirtViewerWindow *self)
>      GtkAllocation allocation;
>      guint width, height;
> 
> +    if (self->priv->display == NULL)
> +        return 0;
> +
>      gtk_widget_get_allocation(GTK_WIDGET(self->priv->display), &allocation);
>      virt_viewer_display_get_desktop_size(self->priv->display, &width, &height);
> 
> Best Regards,
> --
> Fabiano Fidêncio




More information about the virt-tools-list mailing list