summaryrefslogtreecommitdiff
path: root/src/scriptfile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-17 17:47:07 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-17 17:47:07 +0100
commit4748c4bd64610cf943a431d215bb1aad51f8d0b4 (patch)
treea5e483daee891807be23aac8be24587a8da4b26f /src/scriptfile.c
parentbd3a9d2c946bae0427d7c9b9249716064935fb4e (diff)
downloadvim-git-4748c4bd64610cf943a431d215bb1aad51f8d0b4.tar.gz
patch 8.2.4974: ":so" command may read after end of bufferv8.2.4974
Problem: ":so" command may read after end of buffer. Solution: Compute length of text properly.
Diffstat (limited to 'src/scriptfile.c')
-rw-r--r--src/scriptfile.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 03c733d35..f3a5783db 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -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.