From 76fbe2f4541b11af8bcb0b5e57bb155b796b8d8e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 21 Aug 2017 17:46:42 +0300 Subject: [PATCH] Avoid floating-point exceptions while drawing underwave * src/w32term.c (x_get_scale_factor): * src/xterm.c (x_get_scale_factor): Don't let the scale factors become less than 1. Reported by Yuri D'Elia in http://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00459.html. --- src/w32term.c | 6 ++++-- src/xterm.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/w32term.c b/src/w32term.c index 6d2fa335859..2785ae2b52d 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -318,8 +318,10 @@ x_get_scale_factor(struct w32_display_info *dpyinfo, int *scale_x, int *scale_y) if (dpyinfo) { - *scale_x = floor (dpyinfo->resx / base_res); - *scale_y = floor (dpyinfo->resy / base_res); + if (dpyinfo->resx > base_res) + *scale_x = floor (dpyinfo->resx / base_res); + if (dpyinfo->resy > base_res) + *scale_y = floor (dpyinfo->resy / base_res); } } diff --git a/src/xterm.c b/src/xterm.c index 2efa70b1dca..77daa22ae0d 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -3483,8 +3483,10 @@ x_get_scale_factor(Display *disp, int *scale_x, int *scale_y) if (dpyinfo) { - *scale_x = floor (dpyinfo->resx / base_res); - *scale_y = floor (dpyinfo->resy / base_res); + if (dpyinfo->resx > base_res) + *scale_x = floor (dpyinfo->resx / base_res); + if (dpyinfo->resy > base_res) + *scale_y = floor (dpyinfo->resy / base_res); } } -- 2.39.2