mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 15:28:17 +00:00
vim-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)
989f592f7f
This commit is contained in:
@@ -17129,6 +17129,10 @@ static void f_submatch(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (no < 0 || no >= NSUBEXP) {
|
||||||
|
EMSGN(_("E935: invalid submatch number: %d"), no);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int retList = 0;
|
int retList = 0;
|
||||||
|
|
||||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||||
|
@@ -125,6 +125,11 @@ func Test_substitute_expr()
|
|||||||
call assert_equal('--', substitute('xxx', 'x*', {-> '-' . Recurse() . '-'}, ''))
|
call assert_equal('--', substitute('xxx', 'x*', {-> '-' . Recurse() . '-'}, ''))
|
||||||
endfunc
|
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()
|
func Test_substitute_expr_arg()
|
||||||
call assert_equal('123456789-123456789=', substitute('123456789',
|
call assert_equal('123456789-123456789=', substitute('123456789',
|
||||||
\ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
|
\ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',
|
||||||
|
@@ -205,7 +205,7 @@ static int included_patches[] = {
|
|||||||
// 2238 NA
|
// 2238 NA
|
||||||
2237,
|
2237,
|
||||||
// 2236,
|
// 2236,
|
||||||
// 2235,
|
2235,
|
||||||
// 2234 NA
|
// 2234 NA
|
||||||
2233,
|
2233,
|
||||||
// 2232 NA
|
// 2232 NA
|
||||||
|
Reference in New Issue
Block a user