0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.1087: possible memory leak when file expansion fails

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.
This commit is contained in:
Bram Moolenaar
2020-06-29 21:14:51 +02:00
parent cf30643ae6
commit 566cc8c72b
2 changed files with 8 additions and 1 deletions

View 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;