From 6fdaaa06372302f0c35e128d34a9fbd19de9cd00 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 11 Sep 2017 06:40:46 +0000 Subject: Do not free more lines than are available in the history. --- grid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'grid.c') diff --git a/grid.c b/grid.c index c26db476..aa9aea4c 100644 --- a/grid.c +++ b/grid.c @@ -292,12 +292,14 @@ grid_collect_history(struct grid *gd) { u_int ny; - if (gd->hsize < gd->hlimit) + if (gd->hsize == 0 || gd->hsize < gd->hlimit) return; ny = gd->hlimit / 10; if (ny < 1) ny = 1; + if (ny > gd->hsize) + ny = gd->hsize; /* * Free the lines from 0 to ny then move the remaining lines over -- cgit