vim-patch:8.2.3855: illegal memory access when displaying a blob

Problem:    Illegal memory access when displaying a blob.
Solution:   Append a NUL at the end. (Yegappan Lakshmanan, closes vim/vim#9372)
bc404bfb32
This commit is contained in:
VVKot 2021-12-19 19:49:03 +00:00
parent bdfca2028b
commit 6f72236a00
3 changed files with 12 additions and 4 deletions

View File

@ -2565,20 +2565,20 @@ static void nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent)
ga_concat(indent, (char_u *)"| ");
else
ga_concat(indent, (char_u *)" ");
ga_append(indent, '\0');
ga_append(indent, NUL);
nfa_print_state2(debugf, state->out, indent);
/* replace last part of indent for state->out1 */
indent->ga_len -= 3;
ga_concat(indent, (char_u *)" ");
ga_append(indent, '\0');
ga_append(indent, NUL);
nfa_print_state2(debugf, state->out1, indent);
/* shrink indent */
indent->ga_len -= 3;
ga_append(indent, '\0');
ga_append(indent, NUL);
}
/*

View File

@ -346,4 +346,12 @@ func Test_blob_sort()
endif
endfunc
" The following used to cause an out-of-bounds memory access
func Test_blob2string()
let v = '0z' .. repeat('01010101.', 444)
let v ..= '01'
exe 'let b = ' .. v
call assert_equal(v, string(b))
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -113,6 +113,6 @@ endfunc
func Test_echo_string_partial()
function CountSpaces()
endfunction
echomsg function('CountSpaces', [#{aaaaaaaaaaa: v:false, bbbbbbbbbbbb: '', ccccccccccc: ['ab', 'cd']}])
call assert_equal("function('CountSpaces', [{'ccccccccccc': ['ab', 'cd'], 'aaaaaaaaaaa': v:false, 'bbbbbbbbbbbb': ''}])", string(function('CountSpaces', [#{aaaaaaaaaaa: v:false, bbbbbbbbbbbb: '', ccccccccccc: ['ab', 'cd']}])))
endfunc