]> granicus.if.org Git - vim/commitdiff
patch 9.0.1402: crash when using null_class v9.0.1402
authorBram Moolenaar <Bram@vim.org>
Sat, 11 Mar 2023 20:56:35 +0000 (20:56 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 11 Mar 2023 20:56:35 +0000 (20:56 +0000)
Problem:    Crash when using null_class.
Solution:   Give an error when trying to use a null class.

src/testdir/test_vim9_class.vim
src/version.c
src/vim9class.c

index bc8a8e1d548a27fd7e679cf073fe995cb514f2a0..4b6a730bbd7799cb916d502736ef5df446b296c9 100644 (file)
@@ -203,6 +203,13 @@ def Test_returning_null_object()
   v9.CheckScriptSuccess(lines)
 enddef
 
+def Test_using_null_class()
+  var lines =<< trim END
+      @_ = null_class.member
+  END
+  v9.CheckDefExecAndScriptFailure(lines, ['E715:', 'E1363:'])
+enddef
+
 def Test_class_interface_wrong_end()
   var lines =<< trim END
       vim9script
index 0265c47a90f6954cb1c8054ce3ad046ce737fed6..2dca10db9d505930acda7f014ed2ab5f4a867b02 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1402,
 /**/
     1401,
 /**/
index 74664f1b26919e5e685af68ab7d3b3367b3c821f..8174351383bc608809c416c1bb5f2ea95ece69ef 100644 (file)
@@ -1262,6 +1262,12 @@ class_object_index(
        cl = rettv->vval.v_object->obj_class;
     }
 
+    if (cl == NULL)
+    {
+       emsg(_(e_incomplete_type));
+       return FAIL;
+    }
+
     if (*name_end == '(')
     {
        int on_class = rettv->v_type == VAR_CLASS;