From ba31d3a88c8c76ec3c76d9a91373fa24e64797cd Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 3 Jun 2018 10:17:30 +0000 Subject: Increment the lines counter when skipping a line to avoid an infinite loop, and fix a check to avoid a potential out-of-bounds access. Problem reported by Yuxiang Qin and tracked down by Karl Beldan; GitHub issue 1352. Also a man page fix request by jmc@. --- grid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'grid.c') diff --git a/grid.c b/grid.c index f1facc4c..c88a451b 100644 --- a/grid.c +++ b/grid.c @@ -1011,7 +1011,7 @@ grid_reflow_join(struct grid *target, struct grid *gd, u_int sx, u_int yy, * If this is now the last line, there is nothing more to be * done. */ - if (yy + lines == gd->hsize + gd->sy) + if (yy + 1 + lines == gd->hsize + gd->sy) break; line = yy + 1 + lines; @@ -1021,6 +1021,7 @@ grid_reflow_join(struct grid *target, struct grid *gd, u_int sx, u_int yy, if (gd->linedata[line].cellused == 0) { if (!wrapped) break; + lines++; continue; } -- cgit