patch 9.1.1087: Vim9: import with extends may crash
Commit:
https://github.com/vim/vim/commit/645a4288e27f43f88077916fad12f4650bc036a4
Author: Hirohito Higashi <[email protected]>
Date: Sun Feb 9 16:41:23 2025 +0100
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 <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index ff81f4a53..c8dfa1e73 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index b8f783e96..01ce8737b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1087,
/**/
1086,
/**/
diff --git a/src/vim9execute.c b/src/vim9execute.c
index c7f0e673b..50220006b 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2461,8 +2461,14 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
otv = class->class_members_tv;
}
- clear_tv(&otv[lidx]);
- otv[lidx] = *tv;
+ if (otv != NULL)
+ {
+ clear_tv(&otv[lidx]);
+ otv[lidx] = *tv;
+ }
+ else
+ status = FAIL;
+
}
else
{
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1th9Ua-00GYqG-6C%40256bit.org.