mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.3486: illegal memory access with invalid sequence of commands
Problem: Illegal memory access with invalid sequence of commands.
Solution: Do not call leave_block() when not in a try block. (closes vim/vim#8966)
Reset did_emsg so that exception is shown as an error.
cce81e9673
Vim9script is N/A, which includes leave_block.
This commit is contained in:
parent
789558d365
commit
fc954d0a61
@ -1083,7 +1083,7 @@ void ex_endwhile(exarg_T *eap)
|
|||||||
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
|
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
|
||||||
eap->errmsg = err;
|
eap->errmsg = err;
|
||||||
} else {
|
} else {
|
||||||
fl = cstack->cs_flags[cstack->cs_idx];
|
fl = cstack->cs_flags[cstack->cs_idx];
|
||||||
if (!(fl & csf)) {
|
if (!(fl & csf)) {
|
||||||
// If we are in a ":while" or ":for" but used the wrong endloop
|
// If we are in a ":while" or ":for" but used the wrong endloop
|
||||||
// command, do not rewind to the next enclosing ":for"/":while".
|
// command, do not rewind to the next enclosing ":for"/":while".
|
||||||
@ -1575,6 +1575,7 @@ void ex_endtry(exarg_T *eap)
|
|||||||
|
|
||||||
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
|
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
|
||||||
eap->errmsg = get_end_emsg(cstack);
|
eap->errmsg = get_end_emsg(cstack);
|
||||||
|
|
||||||
// Find the matching ":try" and report what's missing.
|
// Find the matching ":try" and report what's missing.
|
||||||
idx = cstack->cs_idx;
|
idx = cstack->cs_idx;
|
||||||
do {
|
do {
|
||||||
@ -1594,6 +1595,9 @@ void ex_endtry(exarg_T *eap)
|
|||||||
if (current_exception) {
|
if (current_exception) {
|
||||||
discard_current_exception();
|
discard_current_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// report eap->errmsg, also when there already was an error
|
||||||
|
did_emsg = false;
|
||||||
} else {
|
} else {
|
||||||
idx = cstack->cs_idx;
|
idx = cstack->cs_idx;
|
||||||
|
|
||||||
@ -1664,8 +1668,10 @@ void ex_endtry(exarg_T *eap)
|
|||||||
*/
|
*/
|
||||||
(void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE);
|
(void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE);
|
||||||
|
|
||||||
--cstack->cs_idx;
|
if (cstack->cs_idx >= 0 && (cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
|
||||||
--cstack->cs_trylevel;
|
cstack->cs_idx--;
|
||||||
|
}
|
||||||
|
cstack->cs_trylevel--;
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
report_resume_pending(pending,
|
report_resume_pending(pending,
|
||||||
|
@ -2067,5 +2067,26 @@ func Test_error_in_catch_and_finally()
|
|||||||
call delete('XtestCatchAndFinally')
|
call delete('XtestCatchAndFinally')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This was causing an illegal memory access
|
||||||
|
func Test_leave_block_in_endtry_not_called()
|
||||||
|
let lines =<< trim END
|
||||||
|
" vim9script
|
||||||
|
" try #
|
||||||
|
try "
|
||||||
|
for x in []
|
||||||
|
if
|
||||||
|
endwhile
|
||||||
|
if
|
||||||
|
endtry
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XtestEndtry')
|
||||||
|
try
|
||||||
|
source XtestEndtry
|
||||||
|
catch /E171:/
|
||||||
|
endtry
|
||||||
|
|
||||||
|
call delete('XtestEndtry')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Modeline {{{1
|
" Modeline {{{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
|
||||||
|
Loading…
Reference in New Issue
Block a user