From 1bced9bf94f2767ad5bb91cc902cd58fc126055e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Sep 2022 13:15:52 +0800 Subject: vim-patch:8.2.4074: going over the end of NameBuff Problem: Going over the end of NameBuff. Solution: Check length when appending a space. https://github.com/vim/vim/commit/de05bb25733c3319e18dca44e9b59c6ee389eb26 --- src/nvim/statusline.c | 9 +++++---- src/nvim/testdir/test_edit.vim | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 665a72b083..33c5c3a347 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -80,10 +80,11 @@ void win_redr_status(win_T *wp) p = (char_u *)NameBuff; len = (int)STRLEN(p); - if (bt_help(wp->w_buffer) - || wp->w_p_pvw - || bufIsChanged(wp->w_buffer) - || wp->w_buffer->b_p_ro) { + if ((bt_help(wp->w_buffer) + || wp->w_p_pvw + || bufIsChanged(wp->w_buffer) + || wp->w_buffer->b_p_ro) + && len < MAXPATHL - 1) { *(p + len++) = ' '; } if (bt_help(wp->w_buffer)) { diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 162f02dd98..a386c4264c 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1983,5 +1983,20 @@ func Test_edit_CTRL_hat() bwipe! endfunc +" Weird long file name was going over the end of NameBuff +func Test_edit_overlong_file_name() + CheckUnix + + file 0000000000000000000000000000 + file %%%%%%%%%%%%%%%%%%%%%%%%%% + file %%%%%% + set readonly + set ls=2 + + redraw! + set noreadonly ls& + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit