From 425d779e15e8d46135b6cc1d0fce518d6c2d584d Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 7 Dec 2023 08:21:13 +0100 Subject: [PATCH] [terminal] Avoid division by zero. Refs #276 --- src/osdep/osdep.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/osdep/osdep.c b/src/osdep/osdep.c index 8af85d9c..e12138c9 100644 --- a/src/osdep/osdep.c +++ b/src/osdep/osdep.c @@ -224,8 +224,13 @@ get_terminal_size(int fd, int *x, int *y, int *cw, int *ch) *x = ws.ws_col; *y = ws.ws_row; - *cw = ws.ws_xpixel / ws.ws_col; - *ch = ws.ws_ypixel / ws.ws_row; + if (ws.ws_col && ws.ws_row && ws.ws_xpixel && ws.ws_ypixel) { + *cw = ws.ws_xpixel / ws.ws_col; + *ch = ws.ws_ypixel / ws.ws_row; + } else { + *cw = 8; + *ch = 16; + } } else { *x = 0; *y = 0;