From c10fe010f1655b1c02c0fa38ea3d969b86a72bcd Mon Sep 17 00:00:00 2001 From: oni-link Date: Fri, 12 Aug 2016 01:10:32 +0200 Subject: Prevent endless loop in printdigraph(). (#5215) Calling printdiagraph() with msg_silent != 0 can result in an endless loop because the loop condition never changes, if msg_col is never changed. To fix this, calculate the number of iterations before the loop, which is always smaller than list_width. --- src/nvim/digraph.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index aad145b3e5..4512b97967 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1691,8 +1691,11 @@ static void printdigraph(digr_T *dp) msg_putchar('\n'); } - if (msg_col) { - while (msg_col % list_width != 0) { + + // Make msg_col a multiple of list_width by using spaces. + if (msg_col % list_width != 0) { + int spaces = (msg_col / list_width + 1) * list_width - msg_col; + while (spaces--) { msg_putchar(' '); } } -- cgit