mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.1205: crash when handling class that extends another class
Problem: Crash when handling class that extends another class with more than one object members. Solution: Correct pointer computations. (closes #11824)
This commit is contained in:
parent
912bfee710
commit
ae3205aa55
@ -1081,6 +1081,26 @@ def Test_class_extends()
|
|||||||
var c = Child.new()
|
var c = Child.new()
|
||||||
END
|
END
|
||||||
v9.CheckScriptFailure(lines, 'E1325: Method not found on class "Child": new(')
|
v9.CheckScriptFailure(lines, 'E1325: Method not found on class "Child": new(')
|
||||||
|
|
||||||
|
# base class with more than one object member
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
class Result
|
||||||
|
this.success: bool
|
||||||
|
this.value: any = null
|
||||||
|
endclass
|
||||||
|
|
||||||
|
class Success extends Result
|
||||||
|
def new(this.value = v:none)
|
||||||
|
this.success = true
|
||||||
|
enddef
|
||||||
|
endclass
|
||||||
|
|
||||||
|
var v = Success.new('asdf')
|
||||||
|
assert_equal("object of Success {success: true, value: 'asdf'}", string(v))
|
||||||
|
END
|
||||||
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_class_import()
|
def Test_class_import()
|
||||||
|
@ -695,6 +695,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 */
|
||||||
|
/**/
|
||||||
|
1205,
|
||||||
/**/
|
/**/
|
||||||
1204,
|
1204,
|
||||||
/**/
|
/**/
|
||||||
|
@ -182,10 +182,11 @@ add_members_to_class(
|
|||||||
for (int i = 0; i < parent_count; ++i)
|
for (int i = 0; i < parent_count; ++i)
|
||||||
{
|
{
|
||||||
// parent members need to be copied
|
// parent members need to be copied
|
||||||
*members[i] = parent_members[i];
|
ocmember_T *m = *members + i;
|
||||||
members[i]->ocm_name = vim_strsave(members[i]->ocm_name);
|
*m = parent_members[i];
|
||||||
if (members[i]->ocm_init != NULL)
|
m->ocm_name = vim_strsave(m->ocm_name);
|
||||||
members[i]->ocm_init = vim_strsave(members[i]->ocm_init);
|
if (m->ocm_init != NULL)
|
||||||
|
m->ocm_init = vim_strsave(m->ocm_init);
|
||||||
}
|
}
|
||||||
if (gap->ga_len > 0)
|
if (gap->ga_len > 0)
|
||||||
// new members are moved
|
// new members are moved
|
||||||
|
Loading…
x
Reference in New Issue
Block a user