diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-06-27 20:15:10 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-06-27 20:15:10 +0100 |
commit | 79481367a457951aabd9501b510fd7e3eb29c3d8 (patch) | |
tree | d9da93e48e64e913dfb838c76da8d0c0fe72ab62 /src/eval.c | |
parent | fee511c1d39ecd155e27545cf70aeaa99d31b215 (diff) |
patch 8.2.5169: nested :source may use NULL pointerv8.2.5169
Problem: Nested :source may use NULL pointer.
Solution: Do not use the NULL pointer.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/eval.c b/src/eval.c index dce78f7f04..42b883e9b0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2387,27 +2387,32 @@ eval0_retarg( 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 (ret != FAIL) + { + expr_end = p; + p = skipwhite(p); - if (nl == NULL) - break; - p = skipwhite(nl + 1); - if (eap != NULL && *p != NUL) - eap->nextcmd = p; - check_for_end = FALSE; - } + // 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 && check_for_end) - end_error = !ends_excmd2(arg, p); if (ret == FAIL || end_error) { if (ret != FAIL) @@ -2433,7 +2438,8 @@ eval0_retarg( // 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] != '|') + if (eap != NULL && p != NULL + && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|') eap->nextcmd = check_nextcmd(p); return FAIL; } |