From 26b7faf1f21c8583587df2e8ed9c3ac3426f677d Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 21 Aug 2021 16:13:51 +0100 Subject: vim-patch:8.2.3357: crash when 'virtualedit' is set and window is narrow Problem: Crash when 'virtualedit' is set and window is narrow. () Solution: Check that width is not zero. (closes vim/vim#8767) https://github.com/vim/vim/commit/02f8694a6bd116ab3316add4a7ea6735bf2e8839 --- src/nvim/cursor.c | 3 ++- src/nvim/testdir/test_number.vim | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index d4a68adeda..21f23b7fd4 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -130,7 +130,8 @@ static int coladvance2( if (finetune && curwin->w_p_wrap && curwin->w_width_inner != 0 - && wcol >= (colnr_T)width) { + && wcol >= (colnr_T)width + && width > 0) { csize = linetabsize(line); if (csize > 0) csize--; diff --git a/src/nvim/testdir/test_number.vim b/src/nvim/testdir/test_number.vim index 92a1bf3c9a..d737ebe9f0 100644 --- a/src/nvim/testdir/test_number.vim +++ b/src/nvim/testdir/test_number.vim @@ -320,4 +320,15 @@ func Test_number_rightleft() bw! endfunc +" This used to cause a divide by zero +func Test_number_no_text_virtual_edit() + vnew + call setline(1, ['line one', 'line two']) + set number virtualedit=all + normal w + 4wincmd | + normal j + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit