vim-patch:8.2.4647: "source" can read past end of copied line

Problem:    "source" can read past end of copied line.
Solution:   Add a terminating NUL.

2bdad61267

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq 2024-04-24 19:52:01 +08:00
parent ffb603b27c
commit 6063975bcf
2 changed files with 11 additions and 0 deletions

View File

@ -2625,7 +2625,9 @@ static char *get_one_sourceline(source_cookie_T *sp)
}
ga_concat(&ga, ((char **)sp->buflines.ga_data)[sp->buf_lnum]);
sp->buf_lnum++;
ga_grow(&ga, 1);
buf = (char *)ga.ga_data;
buf[ga.ga_len++] = NUL;
} else {
buf = ga.ga_data;
retry:

View File

@ -606,4 +606,13 @@ func Test_source_buffer_vim9()
%bw!
endfunc
func Test_source_buffer_long_line()
" This was reading past the end of the line.
new
norm300gr0
so
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab