]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1911: Vim9: segfault with null object and instanceof() v9.0.1911
authorErnie Rael <errael@raelity.com>
Tue, 19 Sep 2023 18:14:18 +0000 (20:14 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 19 Sep 2023 18:14:18 +0000 (20:14 +0200)
Problem:  Vim9: segfault with null object and instanceof()
Solution: return early

closes: #13121

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
src/testdir/test_vim9_class.vim
src/version.c
src/vim9class.c

index fa621b25acf345e0c5d08d1d185746531bbe39ee..1021114a9d28968e37c9f9a4c9a56c0a6771d7fa 100644 (file)
@@ -3032,6 +3032,10 @@ def Test_instanceof()
       assert_true(instanceof(a3, [Base1, Base2, Intf1]))
     enddef
     Foo()
+
+    var o_null: Base1
+    assert_false(instanceof(o_null, Base1))
+
   END
   v9.CheckSourceSuccess(lines)
 enddef
index c2bef2ff57447bb99aff1b0898250eaeb738f398..79b1e11c70a48c35479bc53ea51e3da11d074408 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1911,
 /**/
     1910,
 /**/
index da862f26676060caf5f7b7f067397a5c2bbec44d..f122f90c1f6373b73dff6959aa37e1880ec3f25d 100644 (file)
@@ -2865,6 +2865,9 @@ f_instanceof(typval_T *argvars, typval_T *rettv)
            || check_for_class_or_list_arg(argvars, 1) == FAIL)
        return;
 
+    if (object_tv->vval.v_object == NULL)
+       return;
+
     if (classinfo_tv->v_type == VAR_LIST)
     {
        FOR_ALL_LIST_ITEMS(classinfo_tv->vval.v_list, li)