]> granicus.if.org Git - vim/commitdiff
patch 8.2.3382: crash when getting the type of a NULL partial v8.2.3382
authorBram Moolenaar <Bram@vim.org>
Sat, 28 Aug 2021 12:58:44 +0000 (14:58 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 28 Aug 2021 12:58:44 +0000 (14:58 +0200)
Problem:    Crash when getting the type of a NULL partial.
Solution:   Check for NULL. (closes #8260)

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

index 434f477488704c53a5e896986d0c26b96ef6b469..c166a43a6b464551a313568a8f338c86a2359971 100644 (file)
@@ -3679,6 +3679,15 @@ def Test_typename()
   if has('float')
     assert_equal('func([unknown], [unknown]): float', typename(function('pow')))
   endif
+  assert_equal('func', test_null_partial()->typename())
+  assert_equal('list<unknown>', test_null_list()->typename())
+  assert_equal('dict<unknown>', test_null_dict()->typename())
+  if has('job')
+    assert_equal('job', test_null_job()->typename())
+  endif
+  if has('channel')
+    assert_equal('channel', test_null_channel()->typename())
+  endif
 enddef
 
 def Test_undofile()
index 1fffa738f362eec9ae8bf70556e260a330a4dc9f..77935e5e6c66fe51bcec7befc351bc94a6679692 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3382,
 /**/
     3381,
 /**/
index d6e01cd7a6ba4f3daec0f46908b39a5f9cdcabc9..c14b97fad3c47589efdb39826ad283d01ea37d58 100644 (file)
@@ -327,7 +327,7 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
        char_u  *name = NULL;
        ufunc_T *ufunc = NULL;
 
-       if (tv->v_type == VAR_PARTIAL)
+       if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial != NULL)
        {
            if (tv->vval.v_partial->pt_func != NULL)
                ufunc = tv->vval.v_partial->pt_func;
@@ -382,7 +382,8 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
     type->tt_type = tv->v_type;
     type->tt_argcount = argcount;
     type->tt_min_argcount = min_argcount;
-    if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial->pt_argc > 0)
+    if (tv->v_type == VAR_PARTIAL && tv->vval.v_partial != NULL
+                                           && tv->vval.v_partial->pt_argc > 0)
     {
        type->tt_argcount -= tv->vval.v_partial->pt_argc;
        type->tt_min_argcount -= tv->vval.v_partial->pt_argc;