summaryrefslogtreecommitdiffstats
path: root/layout-set.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-02-03 22:24:34 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-02-03 22:24:34 +0000
commitd6bd9c0e7f6f891774fd9d083bdff2c0e56231dd (patch)
tree57ebc652edfc4d6888fe10eefa31419a5176f2d6 /layout-set.c
parent9ffe549ab199b6af8cd5e7b8ac3611fdba1d6b62 (diff)
Fix divide by zero on small windows with main-* layouts.
Diffstat (limited to 'layout-set.c')
-rw-r--r--layout-set.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/layout-set.c b/layout-set.c
index 2436a0f5..e74a1931 100644
--- a/layout-set.c
+++ b/layout-set.c
@@ -244,6 +244,8 @@ layout_set_main_h(struct window *w)
/* How many rows and columns will be needed? */
columns = w->sx / (PANE_MINIMUM + 1); /* maximum columns */
+ if (columns == 0)
+ columns = 1;
rows = 1 + (n - 1) / columns;
columns = 1 + (n - 1) / rows;
width = w->sx / columns;
@@ -353,6 +355,8 @@ layout_set_main_v(struct window *w)
/* How many rows and columns will be needed? */
rows = w->sy / (PANE_MINIMUM + 1); /* maximum rows */
+ if (rows == 0)
+ rows = 1;
columns = 1 + (n - 1) / rows;
rows = 1 + (n - 1) / columns;
height = w->sy / rows;