Mercurial > vim
changeset 23630:ca98d85e92da v8.2.2357
patch 8.2.2357: Vim9: crash when parsing function return type fails
Commit: https://github.com/vim/vim/commit/648ea76e1d8ca9a9788f88d0d96d0cf0653006bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 15 19:04:32 2021 +0100
patch 8.2.2357: Vim9: crash when parsing function return type fails
Problem: Vim9: crash when parsing function return type fails.
Solution: Bail out and set return type to "unknown". (closes https://github.com/vim/vim/issues/7685)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 15 Jan 2021 19:15:03 +0100 |
parents | b4d2d03559b2 |
children | 552142f8e219 |
files | src/testdir/test_vim9_func.vim src/userfunc.c src/version.c |
diffstat | 3 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -197,6 +197,17 @@ def Test_return_nothing() s:nothing->assert_equal(1) enddef +def Test_return_invalid() + var lines =<< trim END + vim9script + def Func(): invalid + return xxx + enddef + defcompile + END + CheckScriptFailure(lines, 'E1010:', 2) +enddef + func Increment() let g:counter += 1 endfunc
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -3886,6 +3886,12 @@ define_function(exarg_T *eap, char_u *na { p = ret_type; fp->uf_ret_type = parse_type(&p, &fp->uf_type_list, TRUE); + if (fp->uf_ret_type == NULL) + { + fp->uf_ret_type = &t_void; + SOURCING_LNUM = lnum_save; + goto erret; + } } SOURCING_LNUM = lnum_save; }