Mercurial > vim
changeset 27259:59cdcd1e47b8 v8.2.4158
patch 8.2.4158: MS-Windows: memory leak in :browse
Commit: https://github.com/vim/vim/commit/14b8d6ac6b50f2f4f3e7463e4c335f51a512ad30
Author: K.Takata <kentkt@csc.jp>
Date: Thu Jan 20 15:05:22 2022 +0000
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 https://github.com/vim/vim/issues/9574)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 20 Jan 2022 16:15:04 +0100 |
parents | 43d000669fe8 |
children | 450f249d37b7 |
files | src/gui_w32.c src/version.c |
diffstat | 2 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -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;