diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-08-28 14:58:44 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-28 14:58:44 +0200 |
commit | c8103b4c2547ce2044469bcd49e3d55907bd33d1 (patch) | |
tree | edad9a184a3ac542346383229a84a8e4a97d144c | |
parent | 5c56da4de8398566ef96122db44ec93e6c2d483a (diff) | |
download | vim-git-c8103b4c2547ce2044469bcd49e3d55907bd33d1.tar.gz |
patch 8.2.3382: crash when getting the type of a NULL partialv8.2.3382
Problem: Crash when getting the type of a NULL partial.
Solution: Check for NULL. (closes #8260)
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 9 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9type.c | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 434f47748..c166a43a6 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -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() diff --git a/src/version.c b/src/version.c index 1fffa738f..77935e5e6 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3382, +/**/ 3381, /**/ 3380, diff --git a/src/vim9type.c b/src/vim9type.c index d6e01cd7a..c14b97fad 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -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; |