Patch 8.2.1854

8 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 16, 2020, 2:26:00 PM10/16/20
to vim...@googlegroups.com

Patch 8.2.1854
Problem: Vim9: crash when throwing exception for NULL string. (Dhiraj
Mishra)
Solution: Handle NULL string like empty string. (closes #7139)
Files: src/vim9execute.c, src/errors.h, src/testdir/test_vim9_script.vim


*** ../vim-8.2.1853/src/vim9execute.c 2020-10-15 12:46:38.733199522 +0200
--- src/vim9execute.c 2020-10-16 20:24:19.653691212 +0200
***************
*** 1381,1386 ****
--- 1381,1388 ----
tv = STACK_TV_BOT(0);
tv->v_type = VAR_STRING;
tv->v_lock = 0;
+ // This may result in NULL, which should be equivalent to an
+ // empty string.
tv->vval.v_string = get_reg_contents(
iptr->isn_arg.number, GREG_EXPR_SRC);
++ectx.ec_stack.ga_len;
***************
*** 2082,2087 ****
--- 2084,2096 ----
case ISN_THROW:
--ectx.ec_stack.ga_len;
tv = STACK_TV_BOT(0);
+ if (tv->vval.v_string == NULL
+ || *skipwhite(tv->vval.v_string) == NUL)
+ {
+ emsg(_(e_throw_with_empty_string));
+ goto failed;
+ }
+
if (throw_exception(tv->vval.v_string, ET_USER, NULL) == FAIL)
{
vim_free(tv->vval.v_string);
*** ../vim-8.2.1853/src/errors.h 2020-10-10 21:33:42.403033529 +0200
--- src/errors.h 2020-10-16 20:12:45.119531688 +0200
***************
*** 280,283 ****
--- 280,285 ----
INIT(= N_("E1127: Missing name after dot"));
EXTERN char e_endblock_without_block[]
INIT(= N_("E1128: } without {"));
+ EXTERN char e_throw_with_empty_string[]
+ INIT(= N_("E1129: Throw with empty string"));
#endif
*** ../vim-8.2.1853/src/testdir/test_vim9_script.vim 2020-10-15 20:42:16.418311117 +0200
--- src/testdir/test_vim9_script.vim 2020-10-16 20:22:57.889911474 +0200
***************
*** 617,622 ****
--- 617,637 ----
endtry
END
CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ def Func()
+ throw @r
+ enddef
+ var result = ''
+ try
+ Func()
+ catch /E1129:/
+ result = 'caught'
+ endtry
+ assert_equal('caught', result)
+ END
+ CheckScriptSuccess(lines)
enddef

def Test_error_in_nested_function()
*** ../vim-8.2.1853/src/version.c 2020-10-16 19:56:08.581996958 +0200
--- src/version.c 2020-10-16 20:10:17.431916312 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1854,
/**/

--
You can't have everything. Where would you put it?
-- Steven Wright

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages