summaryrefslogtreecommitdiffstats
path: root/debian/patches/CVE-2022-0629.patch
blob: b3348ef23b3d8b2dc8871640a4d40201a892a92f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From 34f8117dec685ace52cd9e578e2729db278163fc Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
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(-)

diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index 8987f3f8dfcd..27b2d73fbfc8 100644
--- 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()
diff --git a/src/testing.c b/src/testing.c
index 448c01c1e964..48ba14d2cafd 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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))
 	{
diff --git a/src/version.c b/src/version.c
index fb1b8476e1a6..b4983661cadc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
     805,
 /**/
     5024,
+/**/
+    4397,
 /**/
     4218,
 /**/