changeset 26642:7fe649a64777 v8.2.3850

patch 8.2.3850: illegal memory access when displaying a partial Commit: https://github.com/vim/vim/commit/2de5371a755abd287dab6ff544924715a76d4abe Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 19 11:06:35 2021 +0000 patch 8.2.3850: illegal memory access when displaying a partial Problem: Illegal memory access when displaying a partial. Solution: Terminate the string with a NUL. (closes https://github.com/vim/vim/issues/9371)
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Dec 2021 12:15:03 +0100
parents 0772d9367e2d
children c1613719988c
files src/eval.c src/testdir/test_messages.vim src/version.c
diffstat 3 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -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;
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3850,
+/**/
     3849,
 /**/
     3848,