]> granicus.if.org Git - vim/commitdiff
patch 8.2.4397: crash when using many composing characters in error message v8.2.4397
authorBram Moolenaar <Bram@vim.org>
Wed, 16 Feb 2022 12:16:19 +0000 (12:16 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 16 Feb 2022 12:16:19 +0000 (12:16 +0000)
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
src/testing.c
src/version.c

index 8987f3f8dfcd3cd08c21bbd983dfb1f991d031c7..27b2d73fbfc80f9185941848de08a0706258ff9b 100644 (file)
@@ -53,6 +53,14 @@ func Test_assert_equal()
   call assert_equal("\b\e\f\n\t\r\\\x01\x7f", 'x')
   call assert_match('Expected ''\\b\\e\\f\\n\\t\\r\\\\\\x01\\x7f'' but got ''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_equal_dict()
index 448c01c1e9648b9d62a4053786d160ece408aadb..48ba14d2cafd5def2c3b2714d3e6cff275d1c134 100644 (file)
@@ -101,7 +101,7 @@ ga_concat_shorten_esc(garray_T *gap, char_u *str)
     {
        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))
        {
index fb1b8476e1a6c7853addb7f07d87f6a807b01ce2..b4983661cadccec86e69acf7b7ce969a36acbde2 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4397,
 /**/
     4396,
 /**/