From 65bcec9e9ba8f134536b9d3db1d5beac26991e17 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Aug 2022 08:58:51 +0800 Subject: vim-patch:9.0.0220: invalid memory access with for loop over NULL string Problem: Invalid memory access with for loop over NULL string. Solution: Make sure mb_ptr2len() consistently returns zero for NUL. https://github.com/vim/vim/commit/f6d39c31d2177549a986d170e192d8351bd571e2 --- src/nvim/mbyte.c | 4 ++-- src/nvim/testdir/test_eval_stuff.vim | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index ca5a3ddbbf..b777d3933f 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -890,9 +890,9 @@ int utf_ptr2len_len(const char_u *p, int size) return len; } -/// Return the number of bytes occupied by a UTF-8 character in a string -/// +/// Return the number of bytes occupied by a UTF-8 character in a string. /// This includes following composing characters. +/// Returns zero for NUL. int utfc_ptr2len(const char *const p_in) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { diff --git a/src/nvim/testdir/test_eval_stuff.vim b/src/nvim/testdir/test_eval_stuff.vim index 811c6c946d..eff1376d3c 100644 --- a/src/nvim/testdir/test_eval_stuff.vim +++ b/src/nvim/testdir/test_eval_stuff.vim @@ -75,6 +75,18 @@ func Test_for_invalid() redraw endfunc +func Test_for_over_null_string() + let save_enc = &enc + " set enc=iso8859 + let cnt = 0 + for c in v:_null_string + let cnt += 1 + endfor + call assert_equal(0, cnt) + + let &enc = save_enc +endfunc + func Test_readfile_binary() new call setline(1, ['one', 'two', 'three']) -- cgit From dd15fa70967a29e535ae189d387f2e813aaa07fb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Aug 2022 09:01:48 +0800 Subject: vim-patch:9.0.0222: no good reason why text objects are only in larger builds Problem: No good reason why text objects are only in larger builds. Solution: Graduate +textobjects. https://github.com/vim/vim/commit/887748742deae3d6de7aa0fdbb042afe1ccf5e7a --- src/nvim/testdir/test_textobjects.vim | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_textobjects.vim b/src/nvim/testdir/test_textobjects.vim index eeb2946a8b..f21d6fcb99 100644 --- a/src/nvim/testdir/test_textobjects.vim +++ b/src/nvim/testdir/test_textobjects.vim @@ -1,7 +1,6 @@ " Test for textobjects source check.vim -CheckFeature textobjects func CpoM(line, useM, expected) new -- cgit