diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-02-04 21:54:07 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-02-04 21:54:07 +0100 |
commit | bfe12043128d75585749f82aebbf4cdd1a7dfe31 (patch) | |
tree | aa8748b5d2b9e4c51f65b5a210580b254a0d9d79 /src/userfunc.c | |
parent | 26e117e9bcc09926d654b5993d61acde6b5749db (diff) | |
download | vim-git-bfe12043128d75585749f82aebbf4cdd1a7dfe31.tar.gz |
patch 8.2.0207: crash when missing member type on list argumentv8.2.0207
Problem: Crash when missing member type on list argument.
Solution: Check for invalid type. (closes #5572)
Diffstat (limited to 'src/userfunc.c')
-rw-r--r-- | src/userfunc.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/userfunc.c b/src/userfunc.c index 2904ee986..ef1d42d12 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -2968,6 +2968,11 @@ ex_function(exarg_T *eap) if (eap->cmdidx == CMD_def) { + int lnum_save = SOURCING_LNUM; + + // error messages are for the first function line + SOURCING_LNUM = sourcing_lnum_top; + // parse the argument types ga_init2(&fp->uf_type_list, sizeof(type_T), 5); @@ -2980,16 +2985,23 @@ ex_function(exarg_T *eap) fp->uf_arg_types = ALLOC_CLEAR_MULT(type_T *, len); if (fp->uf_arg_types != NULL) { - int i; + int i; + type_T *type; for (i = 0; i < len; ++ i) { p = ((char_u **)argtypes.ga_data)[i]; if (p == NULL) // todo: get type from default value - fp->uf_arg_types[i] = &t_any; + type = &t_any; else - fp->uf_arg_types[i] = parse_type(&p, &fp->uf_type_list); + type = parse_type(&p, &fp->uf_type_list); + if (type == NULL) + { + SOURCING_LNUM = lnum_save; + goto errret_2; + } + fp->uf_arg_types[i] = type; } } if (varargs) @@ -3005,6 +3017,11 @@ ex_function(exarg_T *eap) fp->uf_va_type = &t_any; else fp->uf_va_type = parse_type(&p, &fp->uf_type_list); + if (fp->uf_va_type == NULL) + { + SOURCING_LNUM = lnum_save; + goto errret_2; + } } varargs = FALSE; } |