0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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 #9371)
This commit is contained in:
Bram Moolenaar
2021-12-19 11:06:35 +00:00
parent 389b72196e
commit 2de5371a75
3 changed files with 11 additions and 1 deletions

View 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;

View 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

View File

@@ -749,6 +749,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3850,
/**/
3849,
/**/