# HG changeset patch # User Bram Moolenaar # Date 1615667403 -3600 # Node ID 1027495445bc233b350be1c9c1f4c452158f1c39 # Parent a59394b32332804d21721187528af6f2e8c7cdf2 patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary Commit: https://github.com/vim/vim/commit/93e1cae739c32baf28954b64718bab009c6ee2ac Author: Bram Moolenaar Date: Sat Mar 13 21:24:56 2021 +0100 patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary Problem: Vim9: crash when putting an unknown type in a dictionary. (Yegappan Lakshmanan) Solution: Handle a NULL type pointer. diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -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 = {} + 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) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2600, +/**/ 2599, /**/ 2598, diff --git a/src/vim9type.c b/src/vim9type.c --- a/src/vim9type.c +++ b/src/vim9type.c @@ -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 // 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;