summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2021-06-28 12:12:21 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2021-06-28 12:12:21 +0400
commitedba707b32d47977e14f576854f61a0c1a569eab (patch)
treeefb2eaf52570c87beeab575265743d957f1441ad
parent7f1c4578beebf1cd17a285523363704a98c202d0 (diff)
Fix potential div0 crash
gdk_monitor_get_geometry() may return 0-size, and leads to crash: https://bugzilla.redhat.com/show_bug.cgi?id=1941627 Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r--src/spice-widget.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 7ee02a8..afcf45a 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1379,9 +1379,11 @@ static void recalc_geometry(GtkWidget *widget)
width_mm = gdk_monitor_get_width_mm(monitor);
gdk_monitor_get_geometry(monitor, &geometry);
/* FIXME: gives wrong results atm: https://gitlab.gnome.org/GNOME/gtk/-/issues/3066 */
- width_mm = (width_mm * d->ww / geometry.width) / zoom * scale_factor;
- height_mm = (height_mm * d->wh / geometry.height) / zoom * scale_factor;
- has_display_mm = true;
+ if (geometry.width > 0 && geometry.height > 0) {
+ width_mm = (width_mm * d->ww / geometry.width) / zoom * scale_factor;
+ height_mm = (height_mm * d->wh / geometry.height) / zoom * scale_factor;
+ has_display_mm = true;
+ }
}
DISPLAY_DEBUG(display,