aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/digraph.c
diff options
context:
space:
mode:
authoroni-link <knil.ino@gmail.com>2016-08-12 01:10:32 +0200
committerJustin M. Keyes <justinkz@gmail.com>2016-08-11 19:10:32 -0400
commitc10fe010f1655b1c02c0fa38ea3d969b86a72bcd (patch)
tree0c6f32b440491cc71ea3ff6a40cc19b65299d732 /src/nvim/digraph.c
parenta1682281f427ab011930f421e5691cf4bf230df1 (diff)
downloadrneovim-c10fe010f1655b1c02c0fa38ea3d969b86a72bcd.tar.gz
rneovim-c10fe010f1655b1c02c0fa38ea3d969b86a72bcd.tar.bz2
rneovim-c10fe010f1655b1c02c0fa38ea3d969b86a72bcd.zip
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.
Diffstat (limited to 'src/nvim/digraph.c')
-rw-r--r--src/nvim/digraph.c7
1 files changed, 5 insertions, 2 deletions
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(' ');
}
}