diff src/vim9compile.c @ 24061:d6489b4eb14e v8.2.2572

patch 8.2.2572: Vim9: crash when getting the types for a legacy function Commit: https://github.com/vim/vim/commit/18062fcad648540369db5989aac297431119e037 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 5 21:35:47 2021 +0100 patch 8.2.2572: Vim9: crash when getting the types for a legacy function Problem: Vim9: crash when getting the types for a legacy function. Solution: Initialize the type list growarray. (closes https://github.com/vim/vim/issues/7929)
author Bram Moolenaar <Bram@vim.org>
date Fri, 05 Mar 2021 21:45:02 +0100
parents 308d29307910
children 780dec2ffa6b
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -274,7 +274,7 @@ arg_exists(
  * Lookup a script-local variable in the current script, possibly defined in a
  * block that contains the function "cctx->ctx_ufunc".
  * "cctx" is NULL at the script level.
- * if "len" is <= 0 "name" must be NUL terminated.
+ * If "len" is <= 0 "name" must be NUL terminated.
  * Return NULL when not found.
  */
     static sallvar_T *
@@ -8730,6 +8730,8 @@ set_function_type(ufunc_T *ufunc)
     // The type is included in "tt_args".
     if (argcount > 0 || varargs)
     {
+	if (ufunc->uf_type_list.ga_itemsize == 0)
+	    ga_init2(&ufunc->uf_type_list, sizeof(type_T *), 10);
 	ufunc->uf_func_type = alloc_func_type(ufunc->uf_ret_type,
 					   argcount, &ufunc->uf_type_list);
 	// Add argument types to the function type.