forked from aniani/vim
patch 8.2.3771: Vim9: accessing freed memory when checking type
Problem: Vim9: accessing freed memory when checking type. Solution: Make a copy of a function type.
This commit is contained in:
@@ -1224,6 +1224,25 @@ def Test_set_opfunc_to_lambda()
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_lambda_type_allocated()
|
||||
# Check that unreferencing a partial using a lambda can use the variable type
|
||||
# after the lambda has been freed and does not leak memory.
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
|
||||
func MyomniFunc1(val, findstart, base)
|
||||
return a:findstart ? 0 : []
|
||||
endfunc
|
||||
|
||||
var Lambda = (a, b) => MyomniFunc1(19, a, b)
|
||||
&omnifunc = Lambda
|
||||
Lambda = (a, b) => MyomniFunc1(20, a, b)
|
||||
&omnifunc = string(Lambda)
|
||||
Lambda = (a, b) => strlen(a)
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
" Default arg and varargs
|
||||
def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string
|
||||
var res = one .. ',' .. two
|
||||
|
||||
Reference in New Issue
Block a user