[Libreoffice-commits] core.git: cppu/source
Caolán McNamara
caolanm at redhat.com
Thu Jan 8 01:11:09 PST 2015
cppu/source/uno/lbenv.cxx | 13 ++++++-------
cppu/source/uno/lbmap.cxx | 33 +++++++++++++++++----------------
cppu/source/uno/loadmodule.cxx | 6 +++---
cppu/source/uno/loadmodule.hxx | 7 +++----
4 files changed, 29 insertions(+), 30 deletions(-)
New commits:
commit 900a2996c47a6fd32abf324db17bf1526894da36
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jan 7 21:04:04 2015 +0000
coverity#1261762 Resource leak
still leaks the handle of course, but c++izes the code and hides
the leak from coverity as a side-effect
Change-Id: Ieaab1545a98da1d699df93d020f0cb452ddf2516
diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx
index e8fa57d..721005d 100644
--- a/cppu/source/uno/lbenv.cxx
+++ b/cppu/source/uno/lbenv.cxx
@@ -1055,20 +1055,19 @@ static bool loadEnv(OUString const & cLibStem,
#else
// late init with some code from matching uno language binding
// will be unloaded by environment
- oslModule hMod = cppu::detail::loadModule( cLibStem );
+ osl::Module aMod;
+ bool bMod = cppu::detail::loadModule(aMod, cLibStem);
- if (!hMod)
+ if (!bMod)
return false;
OUString aSymbolName(UNO_INIT_ENVIRONMENT);
- uno_initEnvironmentFunc fpInit = (uno_initEnvironmentFunc)
- ::osl_getFunctionSymbol( hMod, aSymbolName.pData );
+ uno_initEnvironmentFunc fpInit = (uno_initEnvironmentFunc)aMod.getSymbol(aSymbolName);
if (!fpInit)
- {
- ::osl_unloadModule( hMod );
return false;
- }
+
+ aMod.release();
#endif
(*fpInit)( pEnv ); // init of environment
diff --git a/cppu/source/uno/lbmap.cxx b/cppu/source/uno/lbmap.cxx
index a887f89..0313022 100644
--- a/cppu/source/uno/lbmap.cxx
+++ b/cppu/source/uno/lbmap.cxx
@@ -337,7 +337,7 @@ static uno_ext_getMappingFunc selectMapFunc( const OUString & rBridgeName )
#else
-static inline oslModule loadModule( const OUString & rBridgeName )
+static inline bool loadModule(osl::Module & rModule, const OUString & rBridgeName)
{
bool bNeg;
{
@@ -347,16 +347,16 @@ static inline oslModule loadModule( const OUString & rBridgeName )
bNeg = (iFind != rData.aNegativeLibs.end());
}
- if (! bNeg)
+ if (!bNeg)
{
- oslModule hModule = cppu::detail::loadModule( rBridgeName );
+ bool bModule = cppu::detail::loadModule(rModule, rBridgeName);
- if (hModule)
- return hModule;
+ if (bModule)
+ return true;
setNegativeBridge( rBridgeName ); // no load again
}
- return 0;
+ return false;
}
#endif
@@ -406,22 +406,22 @@ static Mapping loadExternalMapping(
}
#else
// find proper lib
- oslModule hModule = 0;
+ osl::Module aModule;
+ bool bModule;
OUString aName;
if ( EnvDcp::getTypeName(rFrom.getTypeName()) == UNO_LB_UNO )
- hModule = loadModule( aName = getBridgeName( rTo, rFrom, rAddPurpose ) );
- if (! hModule)
- hModule = loadModule( aName = getBridgeName( rFrom, rTo, rAddPurpose ) );
- if (! hModule)
- hModule = loadModule( aName = getBridgeName( rTo, rFrom, rAddPurpose ) );
+ bModule = loadModule( aModule, aName = getBridgeName( rTo, rFrom, rAddPurpose ) );
+ if (!bModule)
+ bModule = loadModule( aModule, aName = getBridgeName( rFrom, rTo, rAddPurpose ) );
+ if (!bModule)
+ bModule = loadModule( aModule, aName = getBridgeName( rTo, rFrom, rAddPurpose ) );
- if (hModule)
+ if (bModule)
{
OUString aSymbolName( UNO_EXT_GETMAPPING );
uno_ext_getMappingFunc fpGetMapFunc =
- (uno_ext_getMappingFunc)::osl_getFunctionSymbol(
- hModule, aSymbolName.pData );
+ (uno_ext_getMappingFunc)aModule.getSymbol( aSymbolName );
if (fpGetMapFunc)
{
@@ -430,10 +430,11 @@ static Mapping loadExternalMapping(
OSL_ASSERT( aExt.is() );
if (aExt.is())
{
+ aModule.release();
return aExt;
}
}
- ::osl_unloadModule( hModule );
+ aModule.unload();
setNegativeBridge( aName );
}
#endif
diff --git a/cppu/source/uno/loadmodule.cxx b/cppu/source/uno/loadmodule.cxx
index f00936d..1d8ab75 100644
--- a/cppu/source/uno/loadmodule.cxx
+++ b/cppu/source/uno/loadmodule.cxx
@@ -31,16 +31,16 @@ namespace cppu { namespace detail {
#ifndef DISABLE_DYNLOADING
-::oslModule loadModule(rtl::OUString const & name) {
+bool loadModule(osl::Module& rModule, rtl::OUString const & name) {
rtl::OUStringBuffer b;
#if defined SAL_DLLPREFIX
b.append(SAL_DLLPREFIX);
#endif
b.append(name);
b.append(SAL_DLLEXTENSION);
- return ::osl_loadModuleRelative(
+ return rModule.loadRelative(
reinterpret_cast< oslGenericFunction >(&loadModule),
- b.makeStringAndClear().pData,
+ b.makeStringAndClear(),
SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY);
}
diff --git a/cppu/source/uno/loadmodule.hxx b/cppu/source/uno/loadmodule.hxx
index 1062799..a87c7b1 100644
--- a/cppu/source/uno/loadmodule.hxx
+++ b/cppu/source/uno/loadmodule.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_CPPU_SOURCE_UNO_LOADMODULE_HXX
#include "sal/config.h"
-#include "osl/module.h"
+#include <osl/module.hxx>
namespace rtl { class OUString; }
@@ -35,10 +35,9 @@ namespace cppu { namespace detail {
the nucleus of a module name (without any "lib...so", ".dll", etc.
decoration, and without a path).
- @return
- the handle returned by osl_loadModule.
+ @return false if the module could not be loaded, otherwise true
*/
-::oslModule loadModule(::rtl::OUString const & name);
+bool loadModule(osl::Module & rModule, ::rtl::OUString const & name);
#endif
More information about the Libreoffice-commits
mailing list