diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-02-18 10:43:02 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-02-18 11:26:07 +0000 |
commit | f752a223d19fd52d4e1dd7defa3e134388458f18 (patch) | |
tree | e27846d197602228e1da87073646079639e5ae28 /connectivity | |
parent | 88c2e8bf6e13b943f0ada9a00a6863beb8f12e9b (diff) |
coverity#1352441 silence Resource leak
Change-Id: Ib7d771098d640e17a9503d2d780051e916fa6bb3
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/evoab2/EApi.cxx | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/connectivity/source/drivers/evoab2/EApi.cxx b/connectivity/source/drivers/evoab2/EApi.cxx index 342d446e1b88..fc81a1944769 100644 --- a/connectivity/source/drivers/evoab2/EApi.cxx +++ b/connectivity/source/drivers/evoab2/EApi.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include <rtl/ustring.hxx> -#include <osl/module.h> +#include <osl/module.hxx> #define DECLARE_FN_POINTERS 1 #include "EApi.h" static const char *eBookLibNames[] = { @@ -109,12 +109,12 @@ static const ApiMap aClientApiMap38[] = #undef SYM_MAP template<size_t N> static bool -tryLink( oslModule &aModule, const char *pName, const ApiMap (&pMap)[N]) +tryLink( osl::Module &rModule, const char *pName, const ApiMap (&pMap)[N]) { for (size_t i = 0; i < N; ++i) { - SymbolFunc aMethod = reinterpret_cast<SymbolFunc>(osl_getFunctionSymbol - (aModule, OUString::createFromAscii ( pMap[ i ].sym_name ).pData)); + SymbolFunc aMethod = reinterpret_cast<SymbolFunc>( + rModule.getFunctionSymbol(OUString::createFromAscii(pMap[i].sym_name))); if( !aMethod ) { fprintf( stderr, "Warning: missing symbol '%s' in '%s'\n", @@ -128,15 +128,11 @@ tryLink( oslModule &aModule, const char *pName, const ApiMap (&pMap)[N]) bool EApiInit() { - oslModule aModule; - for( guint j = 0; j < G_N_ELEMENTS( eBookLibNames ); j++ ) { - aModule = osl_loadModule( OUString::createFromAscii - ( eBookLibNames[ j ] ).pData, - SAL_LOADMODULE_DEFAULT ); + osl::Module aModule(OUString::createFromAscii(eBookLibNames[j]), SAL_LOADMODULE_DEFAULT); - if( aModule == nullptr) + if (!aModule.is()) continue; if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap)) @@ -144,24 +140,31 @@ bool EApiInit() if (eds_check_version( 3, 6, 0 ) != nullptr) { if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap)) + { + aModule.release(); return true; + } } else if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap)) { if (eds_check_version( 3, 7, 6 ) != nullptr) { if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap36)) + { + aModule.release(); return true; + } } else { if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38)) + { + aModule.release(); return true; + } } } } - - osl_unloadModule( aModule ); } fprintf( stderr, "Can find no compliant libebook client libraries\n" ); return false; |