]> granicus.if.org Git - vim/commitdiff
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary v8.2.2600
authorBram Moolenaar <Bram@vim.org>
Sat, 13 Mar 2021 20:24:56 +0000 (21:24 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 13 Mar 2021 20:24:56 +0000 (21:24 +0100)
Problem:    Vim9: crash when putting an unknown type in a dictionary.
            (Yegappan Lakshmanan)
Solution:   Handle a NULL type pointer.

src/testdir/test_vim9_builtin.vim
src/version.c
src/vim9type.c

index 8ec3db14829f1c1976e041172569aa9736f1b65b..75bbc0c506bd05a7d83479e4b0a8747c730344bf 100644 (file)
@@ -340,6 +340,26 @@ def Test_extend_list_item_type()
   CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1)
 enddef
 
+def Test_extend_with_error_function()
+  var lines =<< trim END
+      vim9script
+      def F()
+        {
+          var m = 10
+        }
+        echo m
+      enddef
+
+      def Test()
+        var d: dict<any> = {}
+        d->extend({A: 10, Func: function('F', [])})
+      enddef
+
+      Test()
+  END
+  CheckScriptFailure(lines, 'E1001: Variable not found: m')
+enddef
+
 def Test_job_info_return_type()
   if has('job')
     job_start(&shell)
index 9a4fa46808d522528042ebf9ea5159e901e6deb1..72d38783d4ed2ca96aaebd5ca267657589e6ee90 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2600,
 /**/
     2599,
 /**/
index d1ada8e96b46c38dc2af50d5bd1374adbe8eec5e..9eda30d6e6260726095db07e7fef0c96cd4f1f52 100644 (file)
@@ -919,6 +919,8 @@ equal_type(type_T *type1, type_T *type2)
 {
     int i;
 
+    if (type1 == NULL || type2 == NULL)
+       return FALSE;
     if (type1->tt_type != type2->tt_type)
        return FALSE;
     switch (type1->tt_type)
@@ -969,12 +971,12 @@ common_type(type_T *type1, type_T *type2, type_T **dest, garray_T *type_gap)
 
     // If either is VAR_UNKNOWN use the other type.  An empty list/dict has no
     // specific type.
-    if (type1->tt_type == VAR_UNKNOWN)
+    if (type1 == NULL || type1->tt_type == VAR_UNKNOWN)
     {
        *dest = type2;
        return;
     }
-    if (type2->tt_type == VAR_UNKNOWN)
+    if (type2 == NULL || type2->tt_type == VAR_UNKNOWN)
     {
        *dest = type1;
        return;