summaryrefslogtreecommitdiffstats
path: root/comphelper/source/container/interfacecontainer2.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper/source/container/interfacecontainer2.cxx')
-rw-r--r--comphelper/source/container/interfacecontainer2.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/comphelper/source/container/interfacecontainer2.cxx b/comphelper/source/container/interfacecontainer2.cxx
index 0881ccbe44cf..a2e2119be0d2 100644
--- a/comphelper/source/container/interfacecontainer2.cxx
+++ b/comphelper/source/container/interfacecontainer2.cxx
@@ -21,6 +21,7 @@
#include <comphelper/interfacecontainer2.hxx>
#include <comphelper/multicontainer2.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
@@ -103,7 +104,7 @@ void OInterfaceIteratorHelper2::remove()
if( bIsList )
{
OSL_ASSERT( nRemain >= 0 &&
- nRemain < static_cast<sal_Int32>(aData.pAsVector->size()) );
+ o3tl::make_unsigned(nRemain) < aData.pAsVector->size() );
rCont.removeInterface( (*aData.pAsVector)[nRemain] );
}
else
@@ -171,6 +172,9 @@ void OInterfaceContainerHelper2::copyAndResetInUse()
sal_Int32 OInterfaceContainerHelper2::addInterface( const Reference<XInterface> & rListener )
{
OSL_ASSERT( rListener.is() );
+ if ( !rListener.is() )
+ return 0;
+
MutexGuard aGuard( rMutex );
if( bInUse )
copyAndResetInUse();
@@ -244,14 +248,10 @@ Reference<XInterface> OInterfaceContainerHelper2::getInterface( sal_Int32 nIndex
{
MutexGuard aGuard( rMutex );
- if( bIsList )
+ if (bIsList)
return (*aData.pAsVector)[nIndex];
- else if( aData.pAsInterface )
- {
- if (nIndex == 0)
- return aData.pAsInterface;
- }
- throw std::out_of_range("index out of range");
+ assert(aData.pAsInterface && nIndex == 0);
+ return aData.pAsInterface;
}
void OInterfaceContainerHelper2::disposeAndClear( const EventObject & rEvt )