patch 9.0.1701: vim9 crash when class member overridden
Commit:
https://github.com/vim/vim/commit/57a02ccf4c75a6abb270194c90be926d5221b3ce
Author: Yegappan Lakshmanan <[email protected]>
Date: Sun Aug 13 10:19:38 2023 +0200
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 <[email protected]>
Co-authored-by: Yegappan Lakshmanan <[email protected]>
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index f1acdf38e..4936c5320 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index ad0b854e0..ddae45403 100644
--- a/src/version.c
+++ b/src/version.c
@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1701,
/**/
1700,
/**/
diff --git a/src/vim9class.c b/src/vim9class.c
index 12b09677b..18f36bdb4 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -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)
--
--
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 on the web visit
https://groups.google.com/d/msgid/vim_dev/E1qV6UB-00HN0T-IK%40256bit.org.