diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-18 10:49:43 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-19 00:12:25 +0100 |
commit | 184ce84226b49a1b4b693f3bb8cc8569c76d864d (patch) | |
tree | 3cee44de71eca510320fb7e3af0e181d87e1c1df /vcl/unx/generic | |
parent | 1c7fa9528f7373e6798b597a42abe38f20a306aa (diff) |
coverity#1426314 silence Resource leak
Change-Id: I266463184f902df11943a23fa4129086c6441783
Reviewed-on: https://gerrit.libreoffice.org/46703
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx/generic')
-rw-r--r-- | vcl/unx/generic/plugadapt/salplug.cxx | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/vcl/unx/generic/plugadapt/salplug.cxx b/vcl/unx/generic/plugadapt/salplug.cxx index a1195dbde18a..c76077a776b4 100644 --- a/vcl/unx/generic/plugadapt/salplug.cxx +++ b/vcl/unx/generic/plugadapt/salplug.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <osl/module.h> +#include <osl/module.hxx> #include <osl/process.h> #include <rtl/bootstrap.hxx> @@ -75,21 +75,20 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals #endif "vclplug_" + rModuleBase + "lo" SAL_DLLEXTENSION ); - oslModule aMod = osl_loadModuleRelative( - reinterpret_cast< oslGenericFunction >( &tryInstance ), aModule.pData, - SAL_LOADMODULE_GLOBAL ); - if( aMod ) + osl::Module aMod; + if (aMod.loadRelative(reinterpret_cast<oslGenericFunction>(&tryInstance), aModule, SAL_LOADMODULE_GLOBAL)) { - salFactoryProc aProc = reinterpret_cast<salFactoryProc>(osl_getAsciiFunctionSymbol( aMod, "create_SalInstance" )); - if( aProc ) + salFactoryProc aProc = reinterpret_cast<salFactoryProc>(aMod.getFunctionSymbol("create_SalInstance")); + if (aProc) { pInst = aProc(); SAL_INFO( "vcl.plugadapt", "sal plugin " << aModule << " produced instance " << pInst); - if( pInst ) + if (pInst) { - pCloseModule = aMod; + pCloseModule = static_cast<oslModule>(aMod); + aMod.release(); #ifndef ANDROID /* @@ -106,8 +105,6 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals } #endif } - else - osl_unloadModule( aMod ); } else { @@ -115,7 +112,6 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals "vcl.plugadapt", "could not load symbol create_SalInstance from shared object " << aModule); - osl_unloadModule( aMod ); } } else if (bForce) |