From ad006bc6b66f335e87c0876d1b77af3541a4b517 Mon Sep 17 00:00:00 2001
From: Nicholas Marriott <nicm@openbsd.org>
Date: Fri, 17 Jul 2009 18:35:11 +0000
Subject: [PATCH] When resizing a screen smaller in alternate screen mode, all
 the lines needed could be consumed by deleting from the bottom, leaving none
 to be removed from the top. In this case, don't call grid_view_delete_lines
 with ny of 0 as this is incorrect and causes a bounds check to fatal error if
 built with -DDEBUG.

---
 screen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/screen.c b/screen.c
index f1a723a3..650278b2 100644
--- a/screen.c
+++ b/screen.c
@@ -183,7 +183,7 @@ screen_resize_y(struct screen *s, u_int sy)
 		available = s->cy;
 		if (gd->flags & GRID_HISTORY)
 			gd->hsize += needed;
-		else if (available > 0) {
+		else if (needed > 0 && available > 0) {
 			if (available > needed)
 				available = needed;
 			grid_view_delete_lines(gd, 0, available);