patch 9.0.1911: Vim9: segfault with null object and instanceof()

Commit: 
https://github.com/vim/vim/commit/3da696db6ac6103eb8f07cf7be23fa0e12c2419d
Author: Ernie Rael <err...@raelity.com>
Date:   Tue Sep 19 20:14:18 2023 +0200

    patch 9.0.1911: Vim9: segfault with null object and instanceof()
    
    Problem:  Vim9: segfault with null object and instanceof()
    Solution: return early
    
    closes: #13121
    
    Signed-off-by: Christian Brabandt <c...@256bit.org>
    Co-authored-by: Ernie Rael <err...@raelity.com>

diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index fa621b25a..1021114a9 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index c2bef2ff5..79b1e11c7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1911,
 /**/
     1910,
 /**/
diff --git a/src/vim9class.c b/src/vim9class.c
index da862f266..f122f90c1 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -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)

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1qifU8-002Hv8-SR%40256bit.org.

Reply via email to