diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-29 21:14:51 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-29 21:14:51 +0200 |
commit | 566cc8c72bb8036f015a435800f28ef9f6a9a3b6 (patch) | |
tree | f261542849a6c11e2b89a34b660e4966a99a8cd7 /src/filepath.c | |
parent | cf30643ae607ae1a97b50e19c622dc8303723fa2 (diff) | |
download | vim-git-566cc8c72bb8036f015a435800f28ef9f6a9a3b6.tar.gz |
patch 8.2.1087: possible memory leak when file expansion failsv8.2.1087
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.
Diffstat (limited to 'src/filepath.c')
-rw-r--r-- | src/filepath.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/filepath.c b/src/filepath.c index 6644e9939..a1e281b0e 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -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; |