Mercurial > vim
comparison src/eval.c @ 29305:949e8978ea43 v8.2.5169
patch 8.2.5169: nested :source may use NULL pointer
Commit: https://github.com/vim/vim/commit/79481367a457951aabd9501b510fd7e3eb29c3d8
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 27 20:15:10 2022 +0100
patch 8.2.5169: nested :source may use NULL pointer
Problem: Nested :source may use NULL pointer.
Solution: Do not use the NULL pointer.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 27 Jun 2022 21:30:03 +0200 |
parents | 036b4d49c4a0 |
children | 842690841d50 |
comparison
equal
deleted
inserted
replaced
29304:584ebb01e999 | 29305:949e8978ea43 |
---|---|
2385 int check_for_end = retarg == NULL; | 2385 int check_for_end = retarg == NULL; |
2386 int end_error = FALSE; | 2386 int end_error = FALSE; |
2387 | 2387 |
2388 p = skipwhite(arg); | 2388 p = skipwhite(arg); |
2389 ret = eval1(&p, rettv, evalarg); | 2389 ret = eval1(&p, rettv, evalarg); |
2390 expr_end = p; | 2390 |
2391 p = skipwhite(p); | 2391 if (ret != FAIL) |
2392 | 2392 { |
2393 // In Vim9 script a command block is not split at NL characters for | 2393 expr_end = p; |
2394 // commands using an expression argument. Skip over a '#' comment to check | 2394 p = skipwhite(p); |
2395 // for a following NL. Require white space before the '#'. | 2395 |
2396 if (in_vim9script() && p > expr_end && retarg == NULL) | 2396 // In Vim9 script a command block is not split at NL characters for |
2397 while (*p == '#') | 2397 // commands using an expression argument. Skip over a '#' comment to |
2398 { | 2398 // check for a following NL. Require white space before the '#'. |
2399 char_u *nl = vim_strchr(p, NL); | 2399 if (in_vim9script() && p > expr_end && retarg == NULL) |
2400 | 2400 while (*p == '#') |
2401 if (nl == NULL) | 2401 { |
2402 break; | 2402 char_u *nl = vim_strchr(p, NL); |
2403 p = skipwhite(nl + 1); | 2403 |
2404 if (eap != NULL && *p != NUL) | 2404 if (nl == NULL) |
2405 eap->nextcmd = p; | 2405 break; |
2406 check_for_end = FALSE; | 2406 p = skipwhite(nl + 1); |
2407 } | 2407 if (eap != NULL && *p != NUL) |
2408 | 2408 eap->nextcmd = p; |
2409 if (ret != FAIL && check_for_end) | 2409 check_for_end = FALSE; |
2410 end_error = !ends_excmd2(arg, p); | 2410 } |
2411 | |
2412 if (check_for_end) | |
2413 end_error = !ends_excmd2(arg, p); | |
2414 } | |
2415 | |
2411 if (ret == FAIL || end_error) | 2416 if (ret == FAIL || end_error) |
2412 { | 2417 { |
2413 if (ret != FAIL) | 2418 if (ret != FAIL) |
2414 clear_tv(rettv); | 2419 clear_tv(rettv); |
2415 /* | 2420 /* |
2431 } | 2436 } |
2432 | 2437 |
2433 // Some of the expression may not have been consumed. Do not check for | 2438 // Some of the expression may not have been consumed. Do not check for |
2434 // a next command to avoid more errors, unless "|" is following, which | 2439 // a next command to avoid more errors, unless "|" is following, which |
2435 // could only be a command separator. | 2440 // could only be a command separator. |
2436 if (eap != NULL && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|') | 2441 if (eap != NULL && p != NULL |
2442 && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|') | |
2437 eap->nextcmd = check_nextcmd(p); | 2443 eap->nextcmd = check_nextcmd(p); |
2438 return FAIL; | 2444 return FAIL; |
2439 } | 2445 } |
2440 | 2446 |
2441 if (retarg != NULL) | 2447 if (retarg != NULL) |