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.
This commit is contained in:
oni-link 2016-08-12 01:10:32 +02:00 committed by Justin M. Keyes
parent a1682281f4
commit c10fe010f1
1 changed files with 5 additions and 2 deletions

View File

@ -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(' ');
}
}