]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1649: attrs allocation and fuzzy growarray could leak v9.1.1649
authorglepnir <glephunter@gmail.com>
Mon, 18 Aug 2025 19:09:18 +0000 (21:09 +0200)
committerChristian Brabandt <cb@256bit.org>
Mon, 18 Aug 2025 19:09:18 +0000 (21:09 +0200)
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>
src/popupmenu.c
src/version.c

index 9456faae3f99b77ad239f44add8412afea6504be..59966ea79d858bb5cf4038db6a9621bb8d3cdf19 100644 (file)
@@ -51,14 +51,13 @@ static int pum_set_selected(int n, int repeat);
     static void
 pum_compute_size(void)
 {
-    int        i;
     int        w;
 
     // Compute the width of the widest match and the widest extra.
     pum_base_width = 0;
     pum_kind_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)
        {
@@ -454,7 +453,14 @@ pum_compute_text_attrs(char_u *text, hlf_T hlf, int user_hlattr)
     leader_len = STRLEN(leader);
 
     if (in_fuzzy)
+    {
        ga = fuzzy_match_str_with_pos(text, leader);
+       if (!ga)
+       {
+           vim_free(attrs);
+           return NULL;
+       }
+    }
 
     while (*ptr != NUL)
     {
index 903c0960d7ee2ae9069674d618c2d9be20f44d15..8f351ed07d41eeb74c336c29666e172aa4901ee6 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1649,
 /**/
     1648,
 /**/