diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-07-02 14:30:18 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-07-03 08:29:41 +0100 |
commit | c80be30203b842c7b6d3145200b120cefb452cb8 (patch) | |
tree | e9b519886eb1282e33279523b5ac7112d18e65e7 /basic/source/uno/namecont.cxx | |
parent | 39d5ba2fda01ffe56c8bcc0c5dbbb2b7d1bdf0fe (diff) |
coverity#706241 Uncaught exception
we've already checked to see if the element exists, so
we know that its not there.
Change-Id: I538c0d48a883d478e4c748d222b21958d083c049
Diffstat (limited to 'basic/source/uno/namecont.cxx')
-rw-r--r-- | basic/source/uno/namecont.cxx | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index de2b91a6b356..ac353509e6c4 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -186,21 +186,25 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement ) } } - -// Methods XNameContainer -void NameContainer::insertByName( const OUString& aName, const Any& aElement ) +void NameContainer::insertCheck(const OUString& aName, const Any& aElement) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) { + NameContainerNameMap::iterator aIt = mHashMap.find(aName); + if( aIt != mHashMap.end() ) + { + throw ElementExistException(); + } + insertNoCheck(aName, aElement); +} + +void NameContainer::insertNoCheck(const OUString& aName, const Any& aElement) + throw(IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception) +{ Type aAnyType = aElement.getValueType(); if( mType != aAnyType ) { throw IllegalArgumentException(); } - NameContainerNameMap::iterator aIt = mHashMap.find( aName ); - if( aIt != mHashMap.end() ) - { - throw ElementExistException(); - } sal_Int32 nCount = mNames.getLength(); mNames.realloc( nCount + 1 ); @@ -236,6 +240,13 @@ void NameContainer::insertByName( const OUString& aName, const Any& aElement ) } } +// Methods XNameContainer +void NameContainer::insertByName( const OUString& aName, const Any& aElement ) + throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) +{ + insertCheck(aName, aElement); +} + void NameContainer::removeByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) { @@ -2492,7 +2503,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name ) } else { - pImplLib->maNameContainer.insertByName( aElementName, aAny ); + pImplLib->maNameContainer.insertNoCheck(aElementName, aAny); } } pImplLib->implSetModified( false ); |