0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -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:
Hirohito Higashi
2025-02-09 16:41:23 +01:00
committed by Christian Brabandt
parent 76bdb82527
commit 645a4288e2
3 changed files with 48 additions and 2 deletions

View File

@@ -3420,4 +3420,42 @@ def Test_imported_class_as_def_func_rettype()
v9.CheckScriptSuccess(lines)
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

View File

@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1087,
/**/
1086,
/**/

View File

@@ -2461,9 +2461,15 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
otv = class->class_members_tv;
}
if (otv != NULL)
{
clear_tv(&otv[lidx]);
otv[lidx] = *tv;
}
else
status = FAIL;
}
else
{
status = FAIL;