summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-09-07 07:19:30 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2018-09-07 11:44:09 +0200
commit58008a0fdd611bb75e4f6922483818ffd2acbc26 (patch)
treeb106d23913899ff069c647a5128cf6f123d7896f /dbaccess
parent5dd1474ca627c1354ebd4c22c890e9fd67afcffa (diff)
Cppcheck: resource leak warning
Change-Id: I855097279cd091c1e8bd665bb0b48ce9279a9ca8 Reviewed-on: https://gerrit.libreoffice.org/60121 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/Executable_odbcconfig.mk4
-rw-r--r--dbaccess/win32/source/odbcconfig/odbcconfig.cxx4
2 files changed, 6 insertions, 2 deletions
diff --git a/dbaccess/Executable_odbcconfig.mk b/dbaccess/Executable_odbcconfig.mk
index ea37824924cd..fdfcbf26f434 100644
--- a/dbaccess/Executable_odbcconfig.mk
+++ b/dbaccess/Executable_odbcconfig.mk
@@ -11,6 +11,10 @@ $(eval $(call gb_Executable_Executable,odbcconfig))
$(eval $(call gb_Executable_set_targettype_gui,odbcconfig,YES))
+$(eval $(call gb_Executable_use_libraries,odbcconfig,\
+ comphelper \
+))
+
$(eval $(call gb_Library_use_sdk_api,odbcconfig))
$(eval $(call gb_Executable_add_exception_objects,odbcconfig,\
diff --git a/dbaccess/win32/source/odbcconfig/odbcconfig.cxx b/dbaccess/win32/source/odbcconfig/odbcconfig.cxx
index f9add1bef2f1..7874bb4c056f 100644
--- a/dbaccess/win32/source/odbcconfig/odbcconfig.cxx
+++ b/dbaccess/win32/source/odbcconfig/odbcconfig.cxx
@@ -23,6 +23,7 @@
#endif
#include <windows.h>
#include <sqlext.h>
+#include <comphelper/scopeguard.hxx>
// the name of the library which contains the SQLManageDataSources function
#define ODBC_UI_LIB_NAME L"ODBCCP32.DLL"
@@ -113,6 +114,7 @@ extern "C" int APIENTRY wWinMain( HINSTANCE _hAppInstance, HINSTANCE, LPWSTR, in
hModule = LoadLibraryExW( ODBC_UI_LIB_NAME, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
if ( hModule == nullptr )
return displayLastError();
+ comphelper::ScopeGuard hModuleReleaser([hModule]() { FreeLibrary(hModule); });
FARPROC pManageDSProc = GetProcAddress( hModule, "SQLManageDataSources" );
if ( pManageDSProc == nullptr )
@@ -122,8 +124,6 @@ extern "C" int APIENTRY wWinMain( HINSTANCE _hAppInstance, HINSTANCE, LPWSTR, in
if ( !( (*pManageDS)( hAppWindow ) ) )
return displayLastError();
- FreeLibrary( hModule );
-
return 0;
}