[virt-tools-list] [PATCH virt-viewer 07/19] Run-time check values before doing bad computation
Christophe Fergeau
cfergeau at redhat.com
Tue Jul 17 09:10:09 UTC 2012
On Mon, Jul 16, 2012 at 06:57:42PM +0200, Marc-André Lureau wrote:
> ---
> src/virt-viewer-display.c | 6 +++++-
> src/virt-viewer-window.c | 5 +++++
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
> index 43ec45e..a954671 100644
> --- a/src/virt-viewer-display.c
> +++ b/src/virt-viewer-display.c
> @@ -403,6 +403,10 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
> DEBUG_LOG("Allocated %dx%d", allocation->width, allocation->height);
> gtk_widget_set_allocation(widget, allocation);
>
> + if (priv->desktopWidth == 0 ||
> + priv->desktopHeight == 0)
> + goto end;
Why can this happen?
> +
> desktopAspect = (double)priv->desktopWidth / (double)priv->desktopHeight;
>
> if (child && gtk_widget_get_visible(child)) {
> @@ -427,7 +431,7 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
> gtk_widget_size_allocate(child, &child_allocation);
> }
>
> -
> +end:
> /* This unsets the size request, so that the user can
> * manually resize the window smaller again
> */
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index c873ebc..4887e28 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -433,6 +433,11 @@ virt_viewer_window_resize(VirtViewerWindow *self)
> (screen, gtk_widget_get_window(priv->window)),
> &fullscreen);
>
> + g_return_if_fail(fullscreen.height > 128);
> + g_return_if_fail(fullscreen.width > 128);
> + g_return_if_fail(desktopWidth > 0);
> + g_return_if_fail(desktopHeight > 0);
In size_allocate 0 width/height are silently ignored, here you return with
a warning, is it on purpose?
Christophe
> +
> desktopAspect = (double)desktopWidth / (double)desktopHeight;
> screenAspect = (double)(fullscreen.width - 128) / (double)(fullscreen.height - 128);
>
> --
> 1.7.10.4
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20120717/65a8e02e/attachment.sig>
More information about the virt-tools-list
mailing list