comparison src/testdir/test_vim9_class.vim @ 33501:c7c630759e31 v9.0.2000

patch 9.0.2000: Vim9: use-after-free in deep call stack Commit: https://github.com/vim/vim/commit/1087b8c29ab521106c5b6cc85d5b38244f0d9c1d Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Oct 7 22:03:18 2023 +0200 patch 9.0.2000: Vim9: use-after-free in deep call stack Problem: Vim9: use-after-free in deep call stack Solution: Get the objct pointer from execution stack closes: #13296 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Sat, 07 Oct 2023 22:15:07 +0200
parents bff8ac203a22
children f72004b37b2b
comparison
equal deleted inserted replaced
33500:665078e8fea1 33501:c7c630759e31
6987 Bar() 6987 Bar()
6988 END 6988 END
6989 call v9.CheckSourceSuccess(lines) 6989 call v9.CheckSourceSuccess(lines)
6990 endfunc 6990 endfunc
6991 6991
6992 " Test for recursively calling an object method. This used to cause an
6993 " use-after-free error.
6994 def Test_recursive_object_method_call()
6995 var lines =<< trim END
6996 vim9script
6997 class A
6998 this.val: number = 0
6999 def Foo(): number
7000 if this.val >= 90
7001 return this.val
7002 endif
7003 this.val += 1
7004 return this.Foo()
7005 enddef
7006 endclass
7007 var a = A.new()
7008 assert_equal(90, a.Foo())
7009 END
7010 v9.CheckSourceSuccess(lines)
7011 enddef
7012
7013 " Test for recursively calling a class method.
7014 def Test_recursive_class_method_call()
7015 var lines =<< trim END
7016 vim9script
7017 class A
7018 static val: number = 0
7019 static def Foo(): number
7020 if val >= 90
7021 return val
7022 endif
7023 val += 1
7024 return Foo()
7025 enddef
7026 endclass
7027 assert_equal(90, A.Foo())
7028 END
7029 v9.CheckSourceSuccess(lines)
7030 enddef
7031
6992 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 7032 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker