0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

patch 8.2.4158: MS-Windows: memory leak in :browse

Problem:    MS-Windows: memory leak in :browse.
Solution:   Free stuff before returning. (Ken Takata, closes #9574)
This commit is contained in:
K.Takata 2022-01-20 15:05:22 +00:00 committed by Bram Moolenaar
parent ae1bd87fe8
commit 14b8d6ac6b
2 changed files with 9 additions and 9 deletions

View File

@ -3587,6 +3587,7 @@ gui_mch_browse(
WCHAR *initdirp = NULL;
WCHAR *filterp;
char_u *p, *q;
BOOL ret;
if (dflt == NULL)
fileBuf[0] = NUL;
@ -3655,22 +3656,19 @@ gui_mch_browse(
fileStruct.Flags |= OFN_NODEREFERENCELINKS;
# endif
if (saving)
{
if (!GetSaveFileNameW(&fileStruct))
return NULL;
}
ret = GetSaveFileNameW(&fileStruct);
else
{
if (!GetOpenFileNameW(&fileStruct))
return NULL;
}
ret = GetOpenFileNameW(&fileStruct);
vim_free(filterp);
vim_free(initdirp);
vim_free(titlep);
vim_free(extp);
// Convert from UCS2 to 'encoding'.
if (!ret)
return NULL;
// Convert from UTF-16 to 'encoding'.
p = utf16_to_enc(fileBuf, NULL);
if (p == NULL)
return NULL;

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4158,
/**/
4157,
/**/