Skip to content

Commit 566cc8c

Browse files
committed
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.
1 parent cf30643 commit 566cc8c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/filepath.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3813,8 +3813,13 @@ gen_expand_wildcards(
38133813
vim_free(p);
38143814
}
38153815

3816+
// When returning FAIL the array must be freed here.
3817+
if (retval == FAIL)
3818+
ga_clear(&ga);
3819+
38163820
*num_file = ga.ga_len;
3817-
*file = (ga.ga_data != NULL) ? (char_u **)ga.ga_data : (char_u **)"";
3821+
*file = (ga.ga_data != NULL) ? (char_u **)ga.ga_data
3822+
: (char_u **)_("no matches");
38183823

38193824
recursive = FALSE;
38203825

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1087,
757759
/**/
758760
1086,
759761
/**/

0 commit comments

Comments
 (0)