patch 9.1.1580: possible memory leak in vim9type.c
Commit:
https://github.com/vim/vim/commit/13e1af7de9daba5f617d24295b8aaf894bf8c201
Author: Lidong Yan <[email protected]>
Date: Tue Jul 22 18:11:11 2025 +0200
patch 9.1.1580: possible memory leak in vim9type.c
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 <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/version.c b/src/version.c
index b5e0da2a2..fa2ebcda9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1580,
/**/
1579,
/**/
diff --git a/src/vim9type.c b/src/vim9type.c
index 62e9344ef..1a20d9bd0 100644
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -1886,8 +1886,10 @@ parse_type_tuple(
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);
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1ueFdx-003tBD-4T%40256bit.org.