diff src/userfunc.c @ 19944:3055cd26e139 v8.2.0528

patch 8.2.0528: Vim9: function arguments insufficiently tested Commit: https://github.com/vim/vim/commit/0b76b42d0a09fb6f1ed79cfc153da4edd6154c89 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 7 22:05:08 2020 +0200 patch 8.2.0528: Vim9: function arguments insufficiently tested Problem: Vim9: function arguments insufficiently tested. Solution: Check types. Add more tests. Fix function with varargs only.
author Bram Moolenaar <Bram@vim.org>
date Tue, 07 Apr 2020 22:15:05 +0200
parents 3ff714d765ba
children 8466e62a2481
line wrap: on
line diff
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -3020,7 +3020,7 @@ ex_function(exarg_T *eap)
 
     if (eap->cmdidx == CMD_def)
     {
-	int lnum_save = SOURCING_LNUM;
+	int	lnum_save = SOURCING_LNUM;
 
 	// error messages are for the first function line
 	SOURCING_LNUM = sourcing_lnum_top;
@@ -3034,7 +3034,8 @@ ex_function(exarg_T *eap)
 	    // and uf_va_type.
 	    int len = argtypes.ga_len - (varargs ? 1 : 0);
 
-	    fp->uf_arg_types = ALLOC_CLEAR_MULT(type_T *, len);
+	    if (len > 0)
+		fp->uf_arg_types = ALLOC_CLEAR_MULT(type_T *, len);
 	    if (fp->uf_arg_types != NULL)
 	    {
 		int	i;