mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.0.1701: vim9 crash when class member overridden
Problem: vim9 crash when class member overridden Solution: Use method_count field instead closes: #12676 closes: #12677 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
committed by
Christian Brabandt
parent
32f586eec1
commit
57a02ccf4c
@@ -1874,5 +1874,43 @@ def Test_defer_with_object()
|
||||
unlet g:result
|
||||
enddef
|
||||
|
||||
" The following test used to crash Vim (Github issue #12676)
|
||||
def Test_extends_method_crashes_vim()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
|
||||
class Observer
|
||||
endclass
|
||||
|
||||
class Property
|
||||
this.value: any
|
||||
|
||||
def Set(v: any)
|
||||
if v != this.value
|
||||
this.value = v
|
||||
endif
|
||||
enddef
|
||||
|
||||
def Register(observer: Observer)
|
||||
enddef
|
||||
endclass
|
||||
|
||||
class Bool extends Property
|
||||
this.value: bool
|
||||
endclass
|
||||
|
||||
def Observe(obj: Property, who: Observer)
|
||||
obj.Register(who)
|
||||
enddef
|
||||
|
||||
var p = Bool.new(false)
|
||||
var myObserver = Observer.new()
|
||||
|
||||
Observe(p, myObserver)
|
||||
|
||||
p.Set(true)
|
||||
END
|
||||
v9.CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1701,
|
||||
/**/
|
||||
1700,
|
||||
/**/
|
||||
|
@@ -897,7 +897,7 @@ early_ret:
|
||||
if (!done && extends_cl != NULL)
|
||||
{
|
||||
for (int cl_i = 0;
|
||||
cl_i < extends_cl->class_obj_member_count; ++cl_i)
|
||||
cl_i < extends_cl->class_obj_method_count; ++cl_i)
|
||||
{
|
||||
if (STRCMP(ifcl->class_obj_methods[if_i]->uf_name,
|
||||
extends_cl->class_obj_methods[cl_i]->uf_name)
|
||||
|
Reference in New Issue
Block a user