Skip to content

Commit

Permalink
[terminal] Avoid division by zero. Refs #276
Browse files Browse the repository at this point in the history
  • Loading branch information
rkd77 committed Dec 7, 2023
1 parent e538a9f commit 425d779
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/osdep/osdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 425d779

Please sign in to comment.