Problem: possible memory leak in vim9type.c
Solution: Free tuple_types_ga if there was an error in
type_type_add_types() (Lidong Yan)
In parse_type_tuple() at src/vim9type.c, we allocate memory
in `tuple_types_ga` by ga_grow(), but forget to free it when
tuple_type_add_types() fails. Replace `return NULL` with `goto on_err`
to fix leak.
closes: #17820
Signed-off-by: Lidong Yan <yldhome2d2@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1580,
/**/
1579,
/**/
ret_type = alloc_tuple_type(typecount, type_gap);
ret_type->tt_flags = flags;
ret_type->tt_argcount = typecount;
- if (tuple_type_add_types(ret_type, typecount, type_gap) == FAIL)
- return NULL;
+ if (tuple_type_add_types(ret_type, typecount, type_gap) == FAIL) {
+ ret_type = NULL;
+ goto on_err;
+ }
mch_memmove(ret_type->tt_args, tuple_types_ga.ga_data,
sizeof(type_T *) * typecount);