summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-25 23:01:42 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-25 23:01:42 +0200
commit1919371b2b9ddb1a645f40b59adbd89317530882 (patch)
tree2b484363ac53680d71826dc360608b505b91cfe5
parent25e0f5863e9010a75a1ff0d04e8f886403968755 (diff)
downloadvim-git-1919371b2b9ddb1a645f40b59adbd89317530882.tar.gz
patch 8.2.0824: still not enough memory allocated when converting stringv8.2.0824
Problem: Still not enough memory allocated when converting string with special character. Solution: Reserve space for expanding K_SPECIAL. (closes #6130)
-rw-r--r--src/eval.c7
-rw-r--r--src/testdir/test_functions.vim1
-rw-r--r--src/version.c2
3 files changed, 7 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c
index d76ec9410..87b764425 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3515,10 +3515,11 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
{
++p;
// A "\<x>" form occupies at least 4 characters, and produces up
- // to 9 characters (6 for the char and 3 for a modifier): reserve
- // space for 5 extra.
+ // to 21 characters (3 * 6 for the char and 3 for a modifier):
+ // reserve space for 18 extra.
+ // Each byte in the char could be encoded as K_SPECIAL K_EXTRA x.
if (*p == '<')
- extra += 5;
+ extra += 18;
}
}
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 712aec4ea..d342e513f 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -2280,6 +2280,7 @@ func Test_nr2char()
call assert_equal('a', nr2char(97, 0))
call assert_equal("\x80\xfc\b\xf4\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\<M-' .. nr2char(0x100000) .. '>"'))
+ call assert_equal("\x80\xfc\b\xfd\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\<M-' .. nr2char(0x40000000) .. '>"'))
endfunc
" Test for screenattr(), screenchar() and screenchars() functions
diff --git a/src/version.c b/src/version.c
index c4648f74f..ce5f627ca 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 824,
+/**/
823,
/**/
822,