Patch 8.2.5169
Problem: Nested :source may use NULL pointer.
Solution: Do not use the NULL pointer.
Files: src/eval.c, src/testdir/test_vimscript.vim
*** ../vim-8.2.5168/src/eval.c 2022-06-03 17:39:43.234182363 +0100
--- src/eval.c 2022-06-27 20:12:12.003193026 +0100
***************
*** 2387,2413 ****
p = skipwhite(arg);
ret = eval1(&p, rettv, evalarg);
- expr_end = p;
- p = skipwhite(p);
! // In Vim9 script a command block is not split at NL characters for
! // commands using an expression argument. Skip over a '#' comment to check
! // for a following NL. Require white space before the '#'.
! if (in_vim9script() && p > expr_end && retarg == NULL)
! while (*p == '#')
! {
! char_u *nl = vim_strchr(p, NL);
! if (nl == NULL)
! break;
! p = skipwhite(nl + 1);
! if (eap != NULL && *p != NUL)
! eap->nextcmd = p;
! check_for_end = FALSE;
! }
- if (ret != FAIL && check_for_end)
- end_error = !ends_excmd2(arg, p);
if (ret == FAIL || end_error)
{
if (ret != FAIL)
--- 2387,2418 ----
p = skipwhite(arg);
ret = eval1(&p, rettv, evalarg);
! if (ret != FAIL)
! {
! expr_end = p;
! p = skipwhite(p);
! // In Vim9 script a command block is not split at NL characters for
! // commands using an expression argument. Skip over a '#' comment to
! // check for a following NL. Require white space before the '#'.
! if (in_vim9script() && p > expr_end && retarg == NULL)
! while (*p == '#')
! {
! char_u *nl = vim_strchr(p, NL);
!
! if (nl == NULL)
! break;
! p = skipwhite(nl + 1);
! if (eap != NULL && *p != NUL)
! eap->nextcmd = p;
! check_for_end = FALSE;
! }
!
! if (check_for_end)
! end_error = !ends_excmd2(arg, p);
! }
if (ret == FAIL || end_error)
{
if (ret != FAIL)
***************
*** 2433,2439 ****
// Some of the expression may not have been consumed. Do not check for
// a next command to avoid more errors, unless "|" is following, which
// could only be a command separator.
! if (eap != NULL && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|')
eap->nextcmd = check_nextcmd(p);
return FAIL;
}
--- 2438,2445 ----
// Some of the expression may not have been consumed. Do not check for
// a next command to avoid more errors, unless "|" is following, which
// could only be a command separator.
! if (eap != NULL && p != NULL
! && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|')
eap->nextcmd = check_nextcmd(p);
return FAIL;
}
*** ../vim-8.2.5168/src/testdir/test_vimscript.vim 2022-05-06 17:53:02.689329537 +0100
--- src/testdir/test_vimscript.vim 2022-06-27 20:12:47.911108654 +0100
***************
*** 7528,7533 ****
--- 7528,7552 ----
call assert_equal('', res)
endfunc
+ " Test for deeply nested :source command {{{1
+ func Test_deeply_nested_source()
+ let lines =<< trim END
+
+ so
+ sil 0scr
+ delete
+ so
+ 0
+ END
+ call writefile(["vim9 silent! @0 \n/"] + lines, 'Xnested.vim')
+
+ " this must not crash
+ let cmd = GetVimCommand() .. " -e -s -S Xnested.vim -c qa!"
+ call system(cmd)
+
+ call delete('Xnested.vim')
+ endfunc
+
"-------------------------------------------------------------------------------
" Modelines {{{1
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.5168/src/version.c 2022-06-27 13:58:54.762444531 +0100
--- src/version.c 2022-06-27 19:42:14.214550450 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 5169,
/**/
--
hundred-and-one symptoms of being an internet addict:
16. You step out of your room and realize that your parents have moved and
you don't have a clue when it happened.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///