summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-11-21 10:25:39 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-11-21 13:57:50 +0100
commit363e0d79bc151fae52bfd11fd3d7c6d9f23af9ad (patch)
tree2cd05e899c55f1d7d780cbaa181a6a9ed34ff235 /sw/source
parentb67ffbda5602b9ffa7964a7ecb5dcd1fc8b998fa (diff)
ofz#4306 Infinite-Loop
Change-Id: Ie52fdbe8d4a6b0432ed8e4d083a718f225e4e326 Reviewed-on: https://gerrit.libreoffice.org/45025 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx22
1 files changed, 10 insertions, 12 deletions
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index bc431c4a9cdd..589af60dce43 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -460,8 +460,7 @@ bool SwWW8ImplReader::SearchRowEnd(WW8PLCFx_Cp_FKP* pPap, WW8_CP &rStartCp,
WW8PLCFxDesc aRes;
aRes.pMemPos = nullptr;
aRes.nEndPos = rStartCp;
- bool bReadRes(false);
- WW8PLCFxDesc aPrevRes;
+ std::set<std::pair<WW8_CP, WW8_CP>> aPrevRes;
while (pPap->HasFkp() && rStartCp != WW8_CP_MAX)
{
@@ -496,13 +495,12 @@ bool SwWW8ImplReader::SearchRowEnd(WW8PLCFx_Cp_FKP* pPap, WW8_CP &rStartCp,
}
pPap->GetSprms(&aRes);
pPap->SetDirty(false);
- if (bReadRes && aRes.nEndPos == aPrevRes.nEndPos && aRes.nStartPos == aPrevRes.nStartPos)
+ auto aBounds(std::make_pair(aRes.nStartPos, aRes.nEndPos));
+ if (!aPrevRes.insert(aBounds).second) //already seen these bounds, infinite loop
{
SAL_WARN("sw.ww8", "SearchRowEnd, loop in paragraph property chain");
break;
}
- bReadRes = true;
- aPrevRes = aRes;
//Update our aRes to get the new starting point of the next properties
rStartCp = aRes.nEndPos;
}
@@ -519,8 +517,7 @@ bool SwWW8ImplReader::SearchTableEnd(WW8PLCFx_Cp_FKP* pPap) const
WW8PLCFxDesc aRes;
aRes.pMemPos = nullptr;
aRes.nEndPos = pPap->Where();
- bool bReadRes(false);
- WW8PLCFxDesc aPrevRes;
+ std::set<std::pair<WW8_CP, WW8_CP>> aPrevRes;
while (pPap->HasFkp() && pPap->Where() != WW8_CP_MAX)
{
@@ -539,11 +536,12 @@ bool SwWW8ImplReader::SearchTableEnd(WW8PLCFx_Cp_FKP* pPap) const
// Read the sprms and make sure we moved forward to avoid infinite loops.
pPap->GetSprms(&aRes);
- if (bReadRes && aRes.nEndPos == aPrevRes.nEndPos && aRes.nStartPos == aPrevRes.nStartPos)
- return false;
-
- bReadRes = true;
- aPrevRes = aRes;
+ auto aBounds(std::make_pair(aRes.nStartPos, aRes.nEndPos));
+ if (!aPrevRes.insert(aBounds).second) //already seen these bounds, infinite loop
+ {
+ SAL_WARN("sw.ww8", "SearchTableEnd, loop in paragraph property chain");
+ break;
+ }
}
return false;