diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-03-27 16:01:51 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-03-27 17:06:38 +0100 |
commit | d9c778391796e91ea3da361bf3901000350c26dd (patch) | |
tree | 17266517f657dea78c3595cf1f09a1caf76dd2b8 /sw/source | |
parent | d5dccc8780c737c0f23164fd98669303e61ba737 (diff) |
tdf#160390: make sure to forward the iterator
Change-Id: I302cc4303f083a1024175ce4ba00ce8021c6d4c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165390
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/html/htmlatr.cxx | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index c880082018f1..f298f93dc5b2 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -1524,8 +1524,9 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart, for (auto it = items.begin(); it != items.end();) { - HTMLStartEndPos* pTest = *it; - sal_Int32 nTestEnd = pTest->GetEnd(); + auto itTest = it++; // forward early, allow 'continue', and keep a copy for 'erase' + HTMLStartEndPos* pTest = *itTest; + const sal_Int32 nTestEnd = pTest->GetEnd(); if (nTestEnd <= nStart) continue; @@ -1533,28 +1534,25 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart, const SfxPoolItem& rTestItem = pTest->GetItem(); // only the corresponding OnTag attributes have to be considered - if (rTestItem.Which() == nWhich && HTML_ON_VALUE == GetHTMLItemState(rTestItem)) - { - // if necessary, insert the second part of the split - // attribute - if (nTestEnd > nEnd) - InsertItem(pTest->GetItem(), nEnd, nTestEnd); + if (rTestItem.Which() != nWhich || HTML_ON_VALUE != GetHTMLItemState(rTestItem)) + continue; - if (nTestStart >= nStart) - { - // the Test item only starts after the new end of the - // attribute. Therefore, it can be completely erased. - it = items.erase(it); - std::erase(m_aEndLst[pTest->GetEnd()], pTest); - delete pTest; - continue; - } + // if necessary, insert the second part of the split attribute + if (nTestEnd > nEnd) + InsertItem(rTestItem, nEnd, nTestEnd); - // the start of the new attribute corresponds to the new - // end of the attribute - FixSplittedItem(pTest, nStart); + if (nTestStart >= nStart) + { + // the Test item only starts after the new end of the + // attribute. Therefore, it can be completely erased. + it = items.erase(itTest); + std::erase(m_aEndLst[nTestEnd], pTest); + delete pTest; + continue; } - ++it; + + // the start of the new attribute corresponds to the new end of the attribute + FixSplittedItem(pTest, nStart); } } } |