mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 9.1.1087: Vim9: import with extends may crash
Problem: Vim9: import with extends may crash Solution: check otv for being NULL before trying to access it (Hirohito Higashi) closes: #16601 Signed-off-by: Hirohito Higashi <h.east.727@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
76bdb82527
commit
645a4288e2
@@ -3420,4 +3420,42 @@ def Test_imported_class_as_def_func_rettype()
|
|||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
" Test for don't crash when using a combination of import and class extends
|
||||||
|
def Test_vim9_import_and_class_extends()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
import './cccc.vim'
|
||||||
|
export class Property extends cccc.Run
|
||||||
|
public var value: string
|
||||||
|
def new(this.value)
|
||||||
|
cccc.Run.value2 = this.value
|
||||||
|
enddef
|
||||||
|
endclass
|
||||||
|
END
|
||||||
|
writefile(lines, './aaaa.vim', 'D')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
export class Run
|
||||||
|
public var value2: string
|
||||||
|
def new(this.value)
|
||||||
|
enddef
|
||||||
|
endclass
|
||||||
|
END
|
||||||
|
writefile(lines, './cccc.vim', 'D')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
import './aaaa.vim'
|
||||||
|
class View
|
||||||
|
var content = aaaa.Property.new('')
|
||||||
|
endclass
|
||||||
|
|
||||||
|
var myView = View.new('This should be ok')
|
||||||
|
assert_equal('This should be ok', myView.content.value)
|
||||||
|
END
|
||||||
|
# TODO: The root cause will be identified later.
|
||||||
|
v9.CheckScriptFailure(lines, 'E1099: Unknown error while executing new', 7)
|
||||||
|
enddef
|
||||||
|
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@@ -704,6 +704,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 */
|
||||||
|
/**/
|
||||||
|
1087,
|
||||||
/**/
|
/**/
|
||||||
1086,
|
1086,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2461,8 +2461,14 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
|
|||||||
otv = class->class_members_tv;
|
otv = class->class_members_tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_tv(&otv[lidx]);
|
if (otv != NULL)
|
||||||
otv[lidx] = *tv;
|
{
|
||||||
|
clear_tv(&otv[lidx]);
|
||||||
|
otv[lidx] = *tv;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = FAIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user