From 14b8d6ac6b50f2f4f3e7463e4c335f51a512ad30 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Thu, 20 Jan 2022 15:05:22 +0000 Subject: [PATCH] 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) --- src/gui_w32.c | 16 +++++++--------- src/version.c | 2 ++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gui_w32.c b/src/gui_w32.c index cbbae9edd..27e36085a 100644 --- 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; diff --git a/src/version.c b/src/version.c index b79f066f5..bde5d7679 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4158, /**/ 4157, /**/ -- 2.50.1