Patch 8.2.3486

7 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 6, 2021, 5:08:52 PM10/6/21
to vim...@googlegroups.com

Patch 8.2.3486
Problem: Illegal memory access with invalid sequence of commands.
Solution: Do not call leave_block() when not in a try block. (closes #8966)
Reset did_emsg so that exception is shown as an error.
Files: src/ex_eval.c, src/testdir/test_trycatch.vim


*** ../vim-8.2.3485/src/ex_eval.c 2021-10-05 11:22:21.549842652 +0100
--- src/ex_eval.c 2021-10-06 22:04:43.830315741 +0100
***************
*** 1385,1391 ****
eap->errmsg = _(err);
else
{
! fl = cstack->cs_flags[cstack->cs_idx];
if (!(fl & csf))
{
// If we are in a ":while" or ":for" but used the wrong endloop
--- 1385,1391 ----
eap->errmsg = _(err);
else
{
! fl = cstack->cs_flags[cstack->cs_idx];
if (!(fl & csf))
{
// If we are in a ":while" or ":for" but used the wrong endloop
***************
*** 2007,2012 ****
--- 2007,2013 ----
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
{
eap->errmsg = get_end_emsg(cstack);
+
// Find the matching ":try" and report what's missing.
idx = cstack->cs_idx;
do
***************
*** 2025,2030 ****
--- 2026,2034 ----
*/
if (did_throw)
discard_current_exception();
+
+ // report eap->errmsg, also when there already was an error
+ did_emsg = FALSE;
}
else
{
***************
*** 2105,2111 ****
*/
(void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE);

! leave_block(cstack);
--cstack->cs_trylevel;

if (!skip)
--- 2109,2117 ----
*/
(void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE);

! if (cstack->cs_idx >= 0
! && (cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
! leave_block(cstack);
--cstack->cs_trylevel;

if (!skip)
*** ../vim-8.2.3485/src/testdir/test_trycatch.vim 2021-10-05 19:27:58.078919775 +0100
--- src/testdir/test_trycatch.vim 2021-10-06 22:06:32.088000307 +0100
***************
*** 2295,2299 ****
--- 2295,2319 ----
call delete('XtestCatchAndFinally')
endfunc

+ " This was causing an illegal memory access
+ func Test_leave_block_in_endtry_not_called()
+ let lines =<< trim END
+ vim9script
+ 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
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.3485/src/version.c 2021-10-06 19:39:12.100052852 +0100
--- src/version.c 2021-10-06 20:06:33.851798624 +0100
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3486,
/**/

--
hundred-and-one symptoms of being an internet addict:
114. You are counting items, you go "0,1,2,3,4,5,6,7,8,9,A,B,C,D...".

/// 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 ///
Reply all
Reply to author
Forward
0 new messages