summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx19
1 files changed, 17 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index e07b12129518..3134c3bc2ed1 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -3382,8 +3382,23 @@ void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
if (nOldEndPos <= nLimitFC)
{
- p->nEndPos = nCpEnd -
- (nLimitFC-nOldEndPos) / (bIsUnicode ? 2 : 1);
+ bFail = o3tl::checked_sub(nLimitFC, nOldEndPos, nCpLen);
+ if (bFail)
+ {
+ SAL_WARN("sw.ww8", "broken offset, ignoring");
+ pPieceIter->SetIdx(nOldPos);
+ return;
+ }
+
+ nCpLen /= (bIsUnicode ? 2 : 1);
+
+ bFail = o3tl::checked_sub(nCpEnd, nCpLen, p->nEndPos);
+ if (bFail)
+ {
+ SAL_WARN("sw.ww8", "broken offset, ignoring");
+ pPieceIter->SetIdx(nOldPos);
+ return;
+ }
}
else
{