[virt-tools-list] [PATCH virt-viewer 07/25] Run-time check values before doing bad computation
Daniel P. Berrange
berrange at redhat.com
Mon Jul 23 14:00:59 UTC 2012
On Tue, Jul 17, 2012 at 09:24:49PM +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;
> +
> 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);
> +
> desktopAspect = (double)desktopWidth / (double)desktopHeight;
> screenAspect = (double)(fullscreen.width - 128) / (double)(fullscreen.height - 128);
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the virt-tools-list
mailing list