0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.4974: ":so" command may read after end of buffer

Problem:    ":so" command may read after end of buffer.
Solution:   Compute length of text properly.
This commit is contained in:
Bram Moolenaar
2022-05-17 17:47:07 +01:00
parent bd3a9d2c94
commit 4748c4bd64
3 changed files with 15 additions and 1 deletions

View File

@@ -1965,6 +1965,7 @@ get_one_sourceline(source_cookie_T *sp)
break;
buf = (char_u *)ga.ga_data;
buf[ga.ga_len++] = NUL;
len = ga.ga_len;
}
else
{
@@ -1972,8 +1973,8 @@ get_one_sourceline(source_cookie_T *sp)
if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
sp->fp) == NULL)
break;
len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);
}
len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);
#ifdef USE_CRNL
// Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the
// CTRL-Z by its own, or after a NL.