summaryrefslogtreecommitdiff
path: root/src/scriptfile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-20 15:02:42 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-20 15:02:42 +0200
commit66250c932e8a0e3c43e7c7c7b1dbede040b9c508 (patch)
tree485324d99b96692841c3f44ad0f76b4c67be4d49 /src/scriptfile.c
parent93ad14710bdf77591f927a2b244bba6a8cbc7706 (diff)
downloadvim-git-66250c932e8a0e3c43e7c7c7b1dbede040b9c508.tar.gz
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with commentv8.2.1491
Problem: Vim9: crash when compiling heredoc lines start with comment. Solution: Skip over NULL pointers. Do not remove comment and empty lines when fetching function lines. (closes #6743)
Diffstat (limited to 'src/scriptfile.c')
-rw-r--r--src/scriptfile.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 4df2c31fe..27d0eb2a5 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1604,7 +1604,9 @@ free_autoload_scriptnames(void)
#endif
linenr_T
-get_sourced_lnum(char_u *(*fgetline)(int, void *, int, int), void *cookie)
+get_sourced_lnum(
+ char_u *(*fgetline)(int, void *, int, getline_opt_T),
+ void *cookie)
{
return fgetline == getsourceline
? ((struct source_cookie *)cookie)->sourcing_lnum
@@ -1724,7 +1726,11 @@ get_one_sourceline(struct source_cookie *sp)
* Return NULL for end-of-file or some error.
*/
char_u *
-getsourceline(int c UNUSED, void *cookie, int indent UNUSED, int do_concat)
+getsourceline(
+ int c UNUSED,
+ void *cookie,
+ int indent UNUSED,
+ getline_opt_T options)
{
struct source_cookie *sp = (struct source_cookie *)cookie;
char_u *line;
@@ -1765,7 +1771,8 @@ getsourceline(int c UNUSED, void *cookie, int indent UNUSED, int do_concat)
// Only concatenate lines starting with a \ when 'cpoptions' doesn't
// contain the 'C' flag.
- if (line != NULL && do_concat && vim_strchr(p_cpo, CPO_CONCAT) == NULL)
+ if (line != NULL && options != GETLINE_NONE
+ && vim_strchr(p_cpo, CPO_CONCAT) == NULL)
{
// compensate for the one line read-ahead
--sp->sourcing_lnum;
@@ -1781,7 +1788,8 @@ getsourceline(int c UNUSED, void *cookie, int indent UNUSED, int do_concat)
|| (p[0] == '"' && p[1] == '\\' && p[2] == ' ')
#ifdef FEAT_EVAL
|| (in_vim9script()
- && (*p == NUL || vim9_comment_start(p)))
+ && options == GETLINE_CONCAT_ALL
+ && (*p == NUL || vim9_comment_start(p)))
#endif
))
{
@@ -1814,7 +1822,8 @@ getsourceline(int c UNUSED, void *cookie, int indent UNUSED, int do_concat)
else if (!(p[0] == '"' && p[1] == '\\' && p[2] == ' ')
#ifdef FEAT_EVAL
&& !(in_vim9script()
- && (*p == NUL || vim9_comment_start(p)))
+ && options == GETLINE_CONCAT_ALL
+ && (*p == NUL || vim9_comment_start(p)))
#endif
)
break;
@@ -1968,7 +1977,7 @@ do_finish(exarg_T *eap, int reanimate)
*/
int
source_finished(
- char_u *(*fgetline)(int, void *, int, int),
+ char_u *(*fgetline)(int, void *, int, getline_opt_T),
void *cookie)
{
return (getline_equal(fgetline, cookie, getsourceline)