Patch 7.4.2235
Problem: submatch() does not check for a valid argument.
Solution: Give an error if the argument is out of range. (Dominique Pelle)
Files: src/evalfunc.c, src/testdir/test_expr.vim
*** ../vim-7.4.2234/src/evalfunc.c 2016-08-21 14:36:11.968845449 +0200
--- src/evalfunc.c 2016-08-21 15:21:22.084628024 +0200
***************
*** 11491,11497 ****
no = (int)get_tv_number_chk(&argvars[0], &error);
if (error)
return;
! error = FALSE;
if (argvars[1].v_type != VAR_UNKNOWN)
retList = (int)get_tv_number_chk(&argvars[1], &error);
if (error)
--- 11491,11501 ----
no = (int)get_tv_number_chk(&argvars[0], &error);
if (error)
return;
! if (no < 0 || no >= NSUBEXP)
! {
! EMSGN(_("E935: invalid submatch number: %d"), no);
! return;
! }
if (argvars[1].v_type != VAR_UNKNOWN)
retList = (int)get_tv_number_chk(&argvars[1], &error);
if (error)
*** ../vim-7.4.2234/src/testdir/test_expr.vim 2016-08-21 14:36:11.968845449
+0200
--- src/testdir/test_expr.vim 2016-08-21 15:23:33.719456292 +0200
***************
*** 198,203 ****
--- 198,208 ----
call assert_equal('--', substitute('xxx', 'x*', {-> '-' . Recurse() . '-'},
''))
endfunc
+ func Test_invalid_submatch()
+ " This was causing invalid memory access in Vim-7.4.2232 and older
+ call assert_fails("call substitute('x', '.', {-> submatch(10)}, '')",
'E935:')
+ endfunc
+
func Test_substitute_expr_arg()
call assert_equal('123456789-123456789=', substitute('123456789',
\ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
*** ../vim-7.4.2234/src/version.c 2016-08-21 14:59:59.916038353 +0200
--- src/version.c 2016-08-21 15:22:47.431868327 +0200
***************
*** 765,766 ****
--- 765,768 ----
{ /* Add new patch number below this line */
+ /**/
+ 2235,
/**/
--
hundred-and-one symptoms of being an internet addict:
39. You move into a new house and decide to Netscape before you landscape.
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.