From 7a7d082e125352a76f54d7fbe5fc67e9cddaf7c9 Mon Sep 17 00:00:00 2001 From: David Bürgin <676c7473@gmail.com> Date: Sun, 3 May 2015 17:03:39 +0200 Subject: vim-patch:7.4.562 #2593 Problem: Segfault with wide screen and error in 'rulerformat'. (Ingo Karkat) Solution: Check there is enough space. (Christian Brabandt) https://github.com/vim/vim/commit/v7-4-562 --- src/nvim/buffer.c | 5 +++++ src/nvim/screen.c | 3 ++- src/nvim/version.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index fd55e8c7a0..b4b36f7fc0 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3511,6 +3511,11 @@ build_stl_str_hl ( */ void get_rel_pos(win_T *wp, char_u *buf, int buflen) { + // Need at least 3 chars for writing. + if (buflen < 3) { + return; + } + long above; /* number of lines above window */ long below; /* number of lines below window */ diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 6e3a4932a8..8b47d090d4 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -7106,7 +7106,8 @@ static void win_redr_ruler(win_T *wp, int always) if (this_ru_col < (width + 1) / 2) this_ru_col = (width + 1) / 2; if (this_ru_col + o < width) { - while (this_ru_col + o < width) { + // Need at least 3 chars left for get_rel_pos() + NUL. + while (this_ru_col + o < width && RULER_BUF_LEN > i + 4) { if (has_mbyte) i += (*mb_char2bytes)(fillchar, buffer + i); else diff --git a/src/nvim/version.c b/src/nvim/version.c index 4d69b9dee9..a77968db93 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -221,7 +221,7 @@ static int included_patches[] = { 565, //564 NA 563, - //562, + 562, 561, //560 NA 559, -- cgit