sc/source/core/data/documen8.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 2a1b6e3cca3e46080890205bc8486889d6e0d530
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Feb 3 21:13:47 2025 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Feb 4 13:05:44 2025 +0100

    crashtesting: SvBaseLink::Update can invalidate later entries
    
    e.g. load forum-mso-en4-62141.xls and update links
    
     #0  sfx2::LinkManager::Remove (this=0x270d720, pLink=0x27b5780) at 
core/sfx2/source/appl/linkmgr2.cxx:118
     #1  0x00007fffa9813eef in ScDocument::UpdateRefAreaLinks (this=0x1f5d740, 
eUpdateRefMode=URM_INSDEL, rRange=..., nDx=0, nDy=-6, nDz=0)
         at core/sc/source/core/data/documen8.cxx:1141
     #2  0x00007fffa97a8639 in ScDocument::UpdateReference (this=0x1f5d740, 
rCxt=..., pUndoDoc=0x0, bIncludeDraw=true, bUpdateNoteCaptionPos=false)
         at core/sc/source/core/data/documen3.cxx:1053
     #3  0x00007fffa9829c9e in ScDocument::DeleteRow (this=0x1f5d740, 
nStartCol=1, nStartTab=0, nEndCol=7, nEndTab=0, nStartRow=3, nSize=6, 
pRefUndoDoc=0x0, pUndoOutline=0x0, pTabMark=0x0)
         at core/sc/source/core/data/document.cxx:1431
     #4  0x00007fffa982a324 in ScDocument::DeleteRow (this=0x1f5d740, 
rRange=...) at core/sc/source/core/data/document.cxx:1484
     #5  0x00007fffa982d1a4 in ScDocument::FitBlock (this=0x1f5d740, rOld=..., 
rNew=..., bClear=true) at core/sc/source/core/data/document.cxx:1883
     #6  0x00007fffaa6c385d in ScAreaLink::Refresh
         (this=0x27b5780, 
rNewFile="http://stocks.tradingcharts.com/stocks/symbols/s/NYSE/Boeing";, 
rNewFilter="calc_HTML_WebQuery", rNewArea="HTML_2", nNewRefreshDelaySeconds=0)
         at core/sc/source/ui/docshell/arealink.cxx:365
     #7  0x00007fffaa6c5069 in ScAreaLink::DataChanged (this=0x27b5780) at 
core/sc/source/ui/docshell/arealink.cxx:128
     #8  0x00007ffff3ac81e1 in sfx2::SvBaseLink::Update (this=0x27b5780) at 
core/sfx2/source/appl/lnkbase2.cxx:324
     #9  0x00007fffa98137b6 in ScDocument::UpdateAreaLinks (this=0x1f5d740) at 
core/sc/source/core/data/documen8.cxx:1058
    
    Change-Id: Ie6c59b240d9a24cbf427be9c5bfda1660fe888c6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181078
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit cdb0c1e5c99cdb9b31e24f50e96a9b254dd9fb33)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181095
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index ca19d460c720..eb84fd3cb2a1 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1051,9 +1051,10 @@ void ScDocument::UpdateAreaLinks()
         return;
 
     const ::sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
-    for (const auto & rLink : rLinks)
+    // Note: SvBaseLink::Update can remove entries after the current one
+    for (size_t i = 0; i < rLinks.size(); ++i)
     {
-        ::sfx2::SvBaseLink* pBase = rLink.get();
+        ::sfx2::SvBaseLink* pBase = rLinks[i].get();
         if (dynamic_cast<const ScAreaLink*>( pBase) !=  nullptr)
             pBase->Update();
     }

Reply via email to