]> granicus.if.org Git - vim/commitdiff
patch 8.2.1087: possible memory leak when file expansion fails v8.2.1087
authorBram Moolenaar <Bram@vim.org>
Mon, 29 Jun 2020 19:14:51 +0000 (21:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 29 Jun 2020 19:14:51 +0000 (21:14 +0200)
Problem:    Possible memory leak when file expansion fails.
Solution:   Clear the grow array when returning FAIL.  Use an error message
            instead of an empty string.

src/filepath.c
src/version.c

index 6644e9939db7e1f7aa37226e877c1ae551918504..a1e281b0eefd3ecbb5d8d3930b5426f9c1e37fc5 100644 (file)
@@ -3813,8 +3813,13 @@ gen_expand_wildcards(
            vim_free(p);
     }
 
+    // When returning FAIL the array must be freed here.
+    if (retval == FAIL)
+       ga_clear(&ga);
+
     *num_file = ga.ga_len;
-    *file = (ga.ga_data != NULL) ? (char_u **)ga.ga_data : (char_u **)"";
+    *file = (ga.ga_data != NULL) ? (char_u **)ga.ga_data
+                                                 : (char_u **)_("no matches");
 
     recursive = FALSE;
 
index 6f6e4810b8eeb084f636796adcdc86971bf0d748..f38c978b2cd35b1d4d3b924d77d23cf31e89ed12 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1087,
 /**/
     1086,
 /**/