diff --git a/README.md b/README.md index e35deb3..8057469 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ release | what's new | date 1.1.2 | test_pickfolder() added | aug 2016 1.1.3 | zenity linux backend added | nov 2017 1.1.3 | fix char type in decls | nov 2017 +1.1.4 | fix win32 memleaks | dec 2018 ## Building ## diff --git a/src/nfd_win.cpp b/src/nfd_win.cpp index f139316..afd6497 100644 --- a/src/nfd_win.cpp +++ b/src/nfd_win.cpp @@ -4,6 +4,10 @@ http://www.frogtoss.com/labs */ +#define _CRTDBG_MAP_ALLOC +#include +#include + /* only locally define UNICODE in this compilation unit */ #ifndef UNICODE #define UNICODE @@ -371,6 +375,7 @@ nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList, if ( !SUCCEEDED(result)) { + fileOpenDialog = NULL; NFDi_SetError("Could not initialize COM."); goto end; } @@ -441,7 +446,8 @@ nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList, nfdResult = NFD_ERROR; } - end: +end: + fileOpenDialog->Release(); ::CoUninitialize(); return nfdResult; @@ -472,6 +478,7 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, if ( !SUCCEEDED(result) ) { + fileOpenDialog = NULL; NFDi_SetError("Could not create dialog."); goto end; } @@ -534,7 +541,10 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, nfdResult = NFD_ERROR; } - end: +end: + if ( fileOpenDialog ) + fileOpenDialog->Release(); + ::CoUninitialize(); return nfdResult; @@ -565,6 +575,7 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, if ( !SUCCEEDED(result) ) { + fileSaveDialog = NULL; NFDi_SetError("Could not create dialog."); goto end; } @@ -624,7 +635,9 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, nfdResult = NFD_ERROR; } - end: +end: + if ( fileSaveDialog ) + fileSaveDialog->Release(); ::CoUninitialize(); return nfdResult;