From 34f8117dec685ace52cd9e578e2729db278163fc Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 16 Feb 2022 12:16:19 +0000 Subject: [PATCH] patch 8.2.4397: crash when using many composing characters in error message Problem: Crash when using many composing characters in error message. Solution: Use mb_cptr2char_adv() instead of mb_ptr2char_adv(). --- src/testdir/test_assert.vim | 8 ++++++++ src/testing.c | 2 +- src/version.c | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) --- a/src/testdir/test_assert.vim +++ b/src/testdir/test_assert.vim @@ -35,6 +35,14 @@ func Test_assert_equal() call assert_equal('XxxxxxxxxxxxxxxxxxxxxxX', 'XyyyyyyyyyyyyyyyyyyyyyyyyyX') call assert_match("Expected 'X\\\\\\[x occurs 21 times]X' but got 'X\\\\\\[y occurs 25 times]X'", v:errors[0]) call remove(v:errors, 0) + + " many composing characters are handled properly + call setline(1, ' ') + norm 100grƯ€ + call assert_equal(1, getline(1)) + call assert_match("Expected 1 but got '.* occurs 100 times]'", v:errors[0]) + call remove(v:errors, 0) + bwipe! endfunc func Test_assert_equalfile() --- a/src/eval.c +++ b/src/eval.c @@ -9558,7 +9558,7 @@ ga_concat_shorten_esc(garray_T *gap, cha { same_len = 1; s = p; - c = mb_ptr2char_adv(&s); + c = mb_cptr2char_adv(&s); clen = s - p; while (*s != NUL && c == mb_ptr2char(s)) { --- a/src/version.c +++ b/src/version.c @@ -796,6 +796,8 @@ static int included_patches[] = /**/ 5024, /**/ + 4397, +/**/ 4218, /**/ 4214,