0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.2.2504: Vim9: crash when using an argument from a closure

Problem:    Vim9: crash when using an argument from a closure.
Solution:   Check if gen_load_outer is NULL. (closes #7821)
This commit is contained in:
Bram Moolenaar
2021-02-12 21:50:57 +01:00
parent d9d7789b6f
commit 44ec21c467
3 changed files with 16 additions and 1 deletions

View File

@@ -1669,6 +1669,18 @@ def Test_closure_using_argument()
unlet g:UseArg unlet g:UseArg
unlet g:UseVararg unlet g:UseVararg
var lines =<< trim END
vim9script
def Test(Fun: func(number): number): list<number>
return map([1, 2, 3], (_, i) => Fun(i))
enddef
def Inc(nr: number): number
return nr + 2
enddef
assert_equal([3, 4, 5], Test(Inc))
END
CheckScriptSuccess(lines)
enddef enddef
def MakeGetAndAppendRefs() def MakeGetAndAppendRefs()

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2504,
/**/ /**/
2503, 2503,
/**/ /**/

View File

@@ -261,7 +261,8 @@ arg_exists(
if (arg_exists(name, len, idxp, type, gen_load_outer, cctx->ctx_outer) if (arg_exists(name, len, idxp, type, gen_load_outer, cctx->ctx_outer)
== OK) == OK)
{ {
++*gen_load_outer; if (gen_load_outer != NULL)
++*gen_load_outer;
return OK; return OK;
} }
} }