connectivity/source/commontools/propertyids.cxx |    1 +
 editeng/source/misc/svxacorr.cxx                |    6 +++++-
 idl/source/cmptools/hash.cxx                    |    1 +
 sc/source/ui/namedlg/namedefdlg.cxx             |    8 ++++++--
 sd/source/ui/func/fupage.cxx                    |    5 ++++-
 slideshow/source/engine/box2dtools.cxx          |   24 ++++++++++++++++++------
 vcl/source/treelist/treelist.cxx                |    7 ++++---
 vcl/source/uitest/uiobject.cxx                  |    1 +
 8 files changed, 40 insertions(+), 13 deletions(-)

New commits:
commit 708e379994591c6e73f07bd2aba136841c9cf036
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Mon Dec 4 18:30:28 2023 +0100
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Mon Dec 4 20:28:26 2023 +0100

    cid#1545810 Using invalid iterator
    
    and :
    
    cid#1545802 Using invalid iterator
    cid#1545745 Using invalid iterator
    cid#1545717 Using invalid iterator
    cid#1545675 Using invalid iterator
    cid#1545668 Using invalid iterator
    cid#1545639 Using invalid iterator
    cid#1545634 Using invalid iterator
    cid#1545629 Using invalid iterator
    cid#1545620 Using invalid iterator
    cid#1545608 Using invalid iterator
    cid#1545607 Using invalid iterator
    cid#1545601 Using invalid iterator
    
    Change-Id: I403842175f64a570d7e52fba7c3e03bf21b7d05b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160320
    Tested-by: Jenkins
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>

diff --git a/connectivity/source/commontools/propertyids.cxx 
b/connectivity/source/commontools/propertyids.cxx
index 90c6beeede6a..cedd0f5f0614 100644
--- a/connectivity/source/commontools/propertyids.cxx
+++ b/connectivity/source/commontools/propertyids.cxx
@@ -95,6 +95,7 @@ namespace dbtools
     const OUString& OPropertyMap::getNameByIndex(sal_Int32 _nIndex) const
     {
         std::map<sal_Int32, OUString>::const_iterator aIter = 
m_aPropertyMap.find(_nIndex);
+        assert(aIter != m_aPropertyMap.end());
         return aIter->second;
     }
 }
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 6fdcbcca1ccf..c8891889b01d 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -1728,7 +1728,11 @@ bool SvxAutoCorrect::AddCplSttException( const OUString& 
rNew,
         if (iter != m_aLangTable.end())
             pLists = &iter->second;
         else if(CreateLanguageFile(aLangTagUndetermined))
-            pLists = &m_aLangTable.find(aLangTagUndetermined)->second;
+        {
+            iter = m_aLangTable.find(aLangTagUndetermined);
+            assert(iter != m_aLangTable.end());
+            pLists = &iter->second;
+        }
     }
     OSL_ENSURE(pLists, "No auto correction data");
     return pLists && pLists->AddToCplSttExceptList(rNew);
diff --git a/idl/source/cmptools/hash.cxx b/idl/source/cmptools/hash.cxx
index d3993881a6ba..4420023bbc32 100644
--- a/idl/source/cmptools/hash.cxx
+++ b/idl/source/cmptools/hash.cxx
@@ -48,6 +48,7 @@ bool SvStringHashTable::Test( const OString& rElement, 
sal_uInt32 * pInsertPos )
 SvStringHashEntry * SvStringHashTable::Get( sal_uInt32 nInsertPos ) const
 {
     auto it = maInt2EntryMap.find(nInsertPos);
+    assert(it != maInt2EntryMap.end());
     return it->second.get();
 }
 
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx 
b/sc/source/ui/namedlg/namedefdlg.cxx
index 5be3ddc7de25..3304f4d39b08 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -125,11 +125,15 @@ bool ScNameDefDlg::IsNameValid()
     ScRangeName* pRangeName = nullptr;
     if(aScope == maGlobalNameStr)
     {
-        pRangeName = maRangeMap.find(STR_GLOBAL_RANGE_NAME)->second;
+        const auto iter = maRangeMap.find(STR_GLOBAL_RANGE_NAME);
+        assert(iter != maRangeMap.end());
+        pRangeName = iter->second;
     }
     else
     {
-        pRangeName = maRangeMap.find(aScope)->second;
+        const auto iter = maRangeMap.find(aScope);
+        assert(iter != maRangeMap.end());
+        pRangeName = iter->second;
     }
 
     ScRangeData::IsNameValidType eType;
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 9401a56b30ec..6d0a59ac3a42 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -548,7 +548,10 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
     if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_CHAR_GRABBAG, true, 
&pPoolItem))
     {
         SfxGrabBagItem const*const pGrabBag(static_cast<SfxGrabBagItem 
const*>(pPoolItem));
-        if (pGrabBag->GetGrabBag().find("BackgroundFullSize")->second >>= 
bFullSize)
+        const auto pGrabBagInner = pGrabBag->GetGrabBag();
+        const auto iter = pGrabBagInner.find("BackgroundFullSize");
+        assert(iter != pGrabBagInner.end());
+        if (iter->second >>= bFullSize)
         {
             if (pMasterPage->IsBackgroundFullSize() != bFullSize)
             {
diff --git a/slideshow/source/engine/box2dtools.cxx 
b/slideshow/source/engine/box2dtools.cxx
index 161bbe8c37f4..e831211d7704 100644
--- a/slideshow/source/engine/box2dtools.cxx
+++ b/slideshow/source/engine/box2dtools.cxx
@@ -284,7 +284,9 @@ void box2DWorld::createStaticFrameAroundSlide(const 
::basegfx::B2DVector& rSlide
 void box2DWorld::setShapePosition(const 
css::uno::Reference<com::sun::star::drawing::XShape> xShape,
                                   const basegfx::B2DPoint& rOutPos)
 {
-    Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(xShape)->second;
+    const auto iter = mpXShapeToBodyMap.find(xShape);
+    assert(iter != mpXShapeToBodyMap.end());
+    Box2DBodySharedPtr pBox2DBody = iter->second;
     pBox2DBody->setPosition(rOutPos);
 }
 
@@ -295,7 +297,9 @@ void box2DWorld::setShapePositionByLinearVelocity(
     assert(mpBox2DWorld);
     if (fPassedTime > 0) // this only makes sense if there was an advance in 
time
     {
-        Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(xShape)->second;
+        const auto iter = mpXShapeToBodyMap.find(xShape);
+        assert(iter != mpXShapeToBodyMap.end());
+        Box2DBodySharedPtr pBox2DBody = iter->second;
         pBox2DBody->setPositionByLinearVelocity(rOutPos, fPassedTime);
     }
 }
@@ -305,14 +309,18 @@ void box2DWorld::setShapeLinearVelocity(
     const basegfx::B2DVector& rVelocity)
 {
     assert(mpBox2DWorld);
-    Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(xShape)->second;
+    const auto iter = mpXShapeToBodyMap.find(xShape);
+    assert(iter != mpXShapeToBodyMap.end());
+    Box2DBodySharedPtr pBox2DBody = iter->second;
     pBox2DBody->setLinearVelocity(rVelocity);
 }
 
 void box2DWorld::setShapeAngle(const 
css::uno::Reference<com::sun::star::drawing::XShape> xShape,
                                const double fAngle)
 {
-    Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(xShape)->second;
+    const auto iter = mpXShapeToBodyMap.find(xShape);
+    assert(iter != mpXShapeToBodyMap.end());
+    Box2DBodySharedPtr pBox2DBody = iter->second;
     pBox2DBody->setAngle(fAngle);
 }
 
@@ -335,7 +343,9 @@ void box2DWorld::setShapeAngularVelocity(
     const double fAngularVelocity)
 {
     assert(mpBox2DWorld);
-    Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(xShape)->second;
+    const auto iter = mpXShapeToBodyMap.find(xShape);
+    assert(iter != mpXShapeToBodyMap.end());
+    Box2DBodySharedPtr pBox2DBody = iter->second;
     pBox2DBody->setAngularVelocity(fAngularVelocity);
 }
 
@@ -343,7 +353,9 @@ void box2DWorld::setShapeCollision(
     const css::uno::Reference<com::sun::star::drawing::XShape> xShape, bool 
bCanCollide)
 {
     assert(mpBox2DWorld);
-    Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(xShape)->second;
+    const auto iter = mpXShapeToBodyMap.find(xShape);
+    assert(iter != mpXShapeToBodyMap.end());
+    Box2DBodySharedPtr pBox2DBody = iter->second;
     pBox2DBody->setCollision(bCanCollide);
 }
 
diff --git a/vcl/source/treelist/treelist.cxx b/vcl/source/treelist/treelist.cxx
index f7eb41311912..a1ebf4d3743c 100644
--- a/vcl/source/treelist/treelist.cxx
+++ b/vcl/source/treelist/treelist.cxx
@@ -1191,9 +1191,10 @@ void SvListView::Impl::RemoveViewData( SvTreeListEntry* 
pParent )
 
 void SvListView::Impl::ActionRemoving( SvTreeListEntry* pEntry )
 {
-    DBG_ASSERT(pEntry,"Remove:No Entry");
-
-    SvViewDataEntry* pViewData = m_DataTable.find( pEntry )->second.get();
+    assert(pEntry && "Remove:No Entry");
+    const auto iter = m_DataTable.find(pEntry);
+    assert(iter != m_DataTable.end());
+    SvViewDataEntry* pViewData = iter->second.get();
     sal_uInt32 nSelRemoved = 0;
     if ( pViewData->IsSelected() )
         nSelRemoved = 1 + m_rThis.pModel->GetChildSelectionCount(&m_rThis, 
pEntry);
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 623591e7e218..d5e1b6f3ebf9 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -1748,6 +1748,7 @@ void MenuButtonUIObject::execute(const OUString& rAction,
     else if (rAction == "OPENFROMLIST")
     {
         auto itr = rParameters.find("POS");
+        assert(itr != rParameters.end());
         sal_uInt32 nPos = itr->second.toUInt32();
 
         sal_uInt32 nId = mxMenuButton->GetPopupMenu()->GetItemId(nPos);

Reply via email to