summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-26 13:15:42 +0100
committerBram Moolenaar <Bram@vim.org>2020-03-26 13:15:42 +0100
commitcf3f8bf4ddfbc0f5ce53f0c9270dc15567f4feea (patch)
treeb29dad3b0af388f98a1c88146a05ec7a66c6beb7
parent0e05de46226eb4e5ea580beefa71831f92d613d3 (diff)
downloadvim-git-cf3f8bf4ddfbc0f5ce53f0c9270dc15567f4feea.tar.gz
patch 8.2.0449: Vim9: crash if return type is invalidv8.2.0449
Problem: Vim9: crash if return type is invalid. (Yegappan Lakshmanan) Solution: Always return some type, not NULL.
-rw-r--r--src/testdir/test_vim9_script.vim3
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c6
3 files changed, 8 insertions, 3 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 9157a1d49..9b49e7cbb 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -269,6 +269,9 @@ def Test_return_type_wrong()
CheckScriptFailure(['def Func(): string', 'return 1', 'enddef'], 'expected string but got number')
CheckScriptFailure(['def Func(): void', 'return "a"', 'enddef'], 'expected void but got string')
CheckScriptFailure(['def Func()', 'return "a"', 'enddef'], 'expected void but got string')
+
+ CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:')
+ CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:')
enddef
def Test_arg_type_wrong()
diff --git a/src/version.c b/src/version.c
index f1d2f66ad..0d7b64179 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 449,
+/**/
448,
/**/
447,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index a595580db..dd3109262 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1375,19 +1375,19 @@ parse_type_member(char_u **arg, type_T *type, garray_T *type_list)
emsg(_("E1007: No white space allowed before <"));
else
emsg(_("E1008: Missing <type>"));
- return NULL;
+ return type;
}
*arg = skipwhite(*arg + 1);
member_type = parse_type(arg, type_list);
if (member_type == NULL)
- return NULL;
+ return type;
*arg = skipwhite(*arg);
if (**arg != '>')
{
emsg(_("E1009: Missing > after type"));
- return NULL;
+ return type;
}
++*arg;