spice-gtk/0001-Fix-potential-div0-crash.patch
Marc-André Lureau bf94d3735b Fix sigfpe. Resolves: rhbz#1941627
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-06-28 20:38:14 +04:00

39 lines
1.5 KiB
Diff

From edba707b32d47977e14f576854f61a0c1a569eab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Mon, 28 Jun 2021 12:12:21 +0400
Subject: [PATCH spice-gtk] Fix potential div0 crash
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
---
src/spice-widget.c | 8 +++++---
1 file 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,
--
2.29.0