mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.5169: nested :source may use NULL pointer
Problem: Nested :source may use NULL pointer. Solution: Do not use the NULL pointer.
This commit is contained in:
14
src/eval.c
14
src/eval.c
@@ -2387,12 +2387,15 @@ eval0_retarg(
|
|||||||
|
|
||||||
p = skipwhite(arg);
|
p = skipwhite(arg);
|
||||||
ret = eval1(&p, rettv, evalarg);
|
ret = eval1(&p, rettv, evalarg);
|
||||||
|
|
||||||
|
if (ret != FAIL)
|
||||||
|
{
|
||||||
expr_end = p;
|
expr_end = p;
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
|
|
||||||
// In Vim9 script a command block is not split at NL characters for
|
// In Vim9 script a command block is not split at NL characters for
|
||||||
// commands using an expression argument. Skip over a '#' comment to check
|
// commands using an expression argument. Skip over a '#' comment to
|
||||||
// for a following NL. Require white space before the '#'.
|
// check for a following NL. Require white space before the '#'.
|
||||||
if (in_vim9script() && p > expr_end && retarg == NULL)
|
if (in_vim9script() && p > expr_end && retarg == NULL)
|
||||||
while (*p == '#')
|
while (*p == '#')
|
||||||
{
|
{
|
||||||
@@ -2406,8 +2409,10 @@ eval0_retarg(
|
|||||||
check_for_end = FALSE;
|
check_for_end = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != FAIL && check_for_end)
|
if (check_for_end)
|
||||||
end_error = !ends_excmd2(arg, p);
|
end_error = !ends_excmd2(arg, p);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret == FAIL || end_error)
|
if (ret == FAIL || end_error)
|
||||||
{
|
{
|
||||||
if (ret != FAIL)
|
if (ret != FAIL)
|
||||||
@@ -2433,7 +2438,8 @@ eval0_retarg(
|
|||||||
// Some of the expression may not have been consumed. Do not check for
|
// Some of the expression may not have been consumed. Do not check for
|
||||||
// a next command to avoid more errors, unless "|" is following, which
|
// a next command to avoid more errors, unless "|" is following, which
|
||||||
// could only be a command separator.
|
// could only be a command separator.
|
||||||
if (eap != NULL && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|')
|
if (eap != NULL && p != NULL
|
||||||
|
&& skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|')
|
||||||
eap->nextcmd = check_nextcmd(p);
|
eap->nextcmd = check_nextcmd(p);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
@@ -7528,6 +7528,25 @@ func Test_for_over_string()
|
|||||||
call assert_equal('', res)
|
call assert_equal('', res)
|
||||||
endfunc
|
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
|
" Modelines {{{1
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@@ -735,6 +735,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
5169,
|
||||||
/**/
|
/**/
|
||||||
5168,
|
5168,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user