From: Bram Moolenaar Date: Mon, 29 Jun 2020 19:14:51 +0000 (+0200) Subject: patch 8.2.1087: possible memory leak when file expansion fails X-Git-Tag: v8.2.1087 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=566cc8c72bb8036f015a435800f28ef9f6a9a3b6;p=vim 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. --- 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; diff --git a/src/version.c b/src/version.c index 6f6e4810b..f38c978b2 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1087, /**/ 1086, /**/