]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3850: illegal memory access when displaying a partial v8.2.3850
authorBram Moolenaar <Bram@vim.org>
Sun, 19 Dec 2021 11:06:35 +0000 (11:06 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 19 Dec 2021 11:06:35 +0000 (11:06 +0000)
Problem:    Illegal memory access when displaying a partial.
Solution:   Terminate the string with a NUL. (closes #9371)

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

index ecc242dcdde32e8eede949395cb0b2ff704d47ac..d0ad7c6e89f62b52128e6b7d43cfabf633d702e7 100644 (file)
@@ -5087,7 +5087,8 @@ echo_string_core(
                    ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID));
                    vim_free(tf);
                }
-               ga_concat(&ga, (char_u *)")");
+               // terminate with ')' and a NUL
+               ga_concat_len(&ga, (char_u *)")", 2);
 
                *tofree = ga.ga_data;
                r = *tofree;
index 375cb014611b97ec0eb08c51478e981bae4f5046..5724eb6a3a4a792856e3e7f233512e73fbe89c33 100644 (file)
@@ -337,4 +337,11 @@ func Test_quit_long_message()
   call delete('Xtest_quit_message')
 endfunc
 
+" this was missing a terminating NUL
+func Test_echo_string_partial()
+  function CountSpaces()
+  endfunction
+  echomsg function('CountSpaces', [#{aaaaaaaaaaa: v:false, bbbbbbbbbbbb: '', ccccccccccc: ['ab', 'cd']}])
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 372b76050f9e47be5becf296b10b757e709669d6..5272a5b8103c0e66a5fd8c33898e8df6f6b16ff8 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3850,
 /**/
     3849,
 /**/