0
0
mirror of https://github.com/vim/vim.git synced 2025-08-23 19:34:27 -04:00

patch 9.1.1649: attrs allocation and fuzzy growarray could leak

Problem:  attrs allocation and fuzzy growarray could leak on early
          returns
Solution: Ensure proper cleanup of allocated memory on exit paths
          (glepnir)

closes: #18038

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
glepnir 2025-08-18 21:09:18 +02:00 committed by Christian Brabandt
parent 2f7e4eb335
commit c7c10f8c11
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 10 additions and 2 deletions

View File

@ -51,14 +51,13 @@ static int pum_set_selected(int n, int repeat);
static void static void
pum_compute_size(void) pum_compute_size(void)
{ {
int i;
int w; int w;
// Compute the width of the widest match and the widest extra. // Compute the width of the widest match and the widest extra.
pum_base_width = 0; pum_base_width = 0;
pum_kind_width = 0; pum_kind_width = 0;
pum_extra_width = 0; pum_extra_width = 0;
for (i = 0; i < pum_size; ++i) for (int i = 0; i < pum_size; ++i)
{ {
if (pum_array[i].pum_text != NULL) if (pum_array[i].pum_text != NULL)
{ {
@ -454,7 +453,14 @@ pum_compute_text_attrs(char_u *text, hlf_T hlf, int user_hlattr)
leader_len = STRLEN(leader); leader_len = STRLEN(leader);
if (in_fuzzy) if (in_fuzzy)
{
ga = fuzzy_match_str_with_pos(text, leader); ga = fuzzy_match_str_with_pos(text, leader);
if (!ga)
{
vim_free(attrs);
return NULL;
}
}
while (*ptr != NUL) while (*ptr != NUL)
{ {

View File

@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1649,
/**/ /**/
1648, 1648,
/**/ /**/