patch 9.1.1581: possible memory leak in vim9generics.c Commit: https://github.com/vim/vim/commit/97194523d599dff8ca4275e49a098271a2696661 Author: Lidong Yan <yldhome...@gmail.com> Date: Tue Jul 22 18:15:57 2025 +0200
patch 9.1.1581: possible memory leak in vim9generics.c Problem: possible memory leak in vim9generics.c Solution: Free ret_free if ga_grow() fails and before returning (Lidong Yan). In parse_generic_func_type_args() at vim9generics.c, we allocate memory in ret_name and should free it by calling vim_free(ret_free). If ga_grow on gfatab->gfat_args failed, we forget to call vim_free(ret_free) thus would cause a leak. Add vim_free(ret_free) before return NULL. closes: #17821 Signed-off-by: Lidong Yan <yldhome...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/version.c b/src/version.c index fa2ebcda9..9a371ef2c 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 */ +/**/ + 1581, /**/ 1580, /**/ diff --git a/src/vim9generics.c b/src/vim9generics.c index 1452610a3..fc45af73c 100644 --- a/src/vim9generics.c +++ b/src/vim9generics.c @@ -305,8 +305,10 @@ parse_generic_func_type_args( char *ret_name = type_name(type_arg, &ret_free); // create space for the name and the new type - if (ga_grow(&gfatab->gfat_args, 1) == FAIL) + if (ga_grow(&gfatab->gfat_args, 1) == FAIL) { + vim_free(ret_free); return NULL; + } generic_arg = (generic_T *)gfatab->gfat_args.ga_data + gfatab->gfat_args.ga_len; gfatab->gfat_args.ga_len++; -- -- 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 vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1ueFsR-003ubO-R9%40256bit.org.