vim-patch:8.2.4625: old Coverity warning for resource leak

Problem:    Old Coverity warning for resource leak.
Solution:   Call FreeWild() if expanding matches did not fail.
90da27b927
This commit is contained in:
zeertzjq
2022-07-27 11:55:32 +08:00
parent f586131e57
commit bbad7371db

View File

@@ -5580,12 +5580,15 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
// Note: We cannot just do `&NameBuff` because it is a statically sized array
// so `NameBuff == &NameBuff` according to C semantics.
char *buff_list[1] = { (char *)NameBuff };
if (gen_expand_wildcards(1, (char_u **)buff_list, &filecount, (char_u ***)&files,
EW_FILE|EW_SILENT) == FAIL
|| filecount == 0) {
const int res = gen_expand_wildcards(1, (char_u **)buff_list, &filecount, (char_u ***)&files,
EW_FILE|EW_SILENT);
if (res == FAIL || filecount == 0) {
if (!got_int) {
semsg(_("E151: No match: %s"), NameBuff);
}
if (res != FAIL) {
FreeWild(filecount, (char_u **)files);
}
return;
}