]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0824: still not enough memory allocated when converting string v8.2.0824
authorBram Moolenaar <Bram@vim.org>
Mon, 25 May 2020 21:01:42 +0000 (23:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 25 May 2020 21:01:42 +0000 (23:01 +0200)
Problem:    Still not enough memory allocated when converting string with
            special character.
Solution:   Reserve space for expanding K_SPECIAL. (closes #6130)

src/eval.c
src/testdir/test_functions.vim
src/version.c

index d76ec94102a703b7d472d699644ba5731fa9cfd6..87b7644251353d3a47f4376bb1840e6fbd578583 100644 (file)
@@ -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;
        }
     }
 
index 712aec4eae2e20c2c4f210c806050ab100b454aa..d342e513ffe65af4c022daffb33bd0814d652ffb 100644 (file)
@@ -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
index c4648f74f99a612c3e2ff29cafe7bfc501243648..ce5f627ca26ae0672699529bde7e3e2aa74bb372 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    824,
 /**/
     823,
 /**/