diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-04-07 13:21:57 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-04-07 16:35:11 +0200 |
commit | 7a89821b85dd20ec79a61aab3bd2b6c8e71f4939 (patch) | |
tree | a374873453ec15e78931646c82b0fff8566fa4d2 /sw/source/filter/ww8/ww8par5.cxx | |
parent | e81385277c091dabb1f6542a94229d7dcc77289b (diff) |
ofz#46457 don't crash with mangled INCLUDETEXT field case
Change-Id: I86621bce8587aeeeded90bc81ae9f17049c17f42
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132667
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/filter/ww8/ww8par5.cxx')
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index a78fa37f2e45..661a0d549691 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -590,9 +590,21 @@ sal_uInt16 SwWW8ImplReader::End_Field() break; case ww::eMERGEINC: case ww::eINCLUDETEXT: + { //Move outside the section associated with this type of field - *m_pPaM->GetPoint() = m_aFieldStack.back().maStartPos; + SwPosition aRestorePos(m_aFieldStack.back().maStartPos); + + SwContentNode* pNd = aRestorePos.nNode.GetNode().GetContentNode(); + sal_Int32 nMaxValidIndex = pNd ? pNd->Len() : 0; + if (aRestorePos.nContent.GetIndex() > nMaxValidIndex) + { + SAL_WARN("sw.ww8", "Attempt to restore to invalid content position"); + aRestorePos.nContent.Assign(pNd, nMaxValidIndex); + } + + *m_pPaM->GetPoint() = aRestorePos; break; + } case ww::eIF: // IF-field { // conditional field parameters |