sw/qa/core/data/ww6/pass/crash-7.doc |binary sw/source/filter/basflt/fltshell.cxx | 26 ++++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-)
New commits: commit e1276f7bd5a396f23856d039f3e79e20aa8232fc Author: Caolán McNamara <caol...@redhat.com> Date: Sun Aug 23 17:13:23 2015 +0100 check for bad locations (cherry picked from commit b164d08f0c12a3434fad1b40900ddc8cb510370c) Change-Id: I635585f664e700047d92821fb965d42b803a8a15 Reviewed-on: https://gerrit.libreoffice.org/17939 Reviewed-by: David Tardon <dtar...@redhat.com> Tested-by: David Tardon <dtar...@redhat.com> diff --git a/sw/qa/core/data/ww6/pass/crash-7.doc b/sw/qa/core/data/ww6/pass/crash-7.doc new file mode 100644 index 0000000..5a9dab3 Binary files /dev/null and b/sw/qa/core/data/ww6/pass/crash-7.doc differ diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index 549731a..ef46c21 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -419,25 +419,33 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos, return pRet; } -static void MakePoint(const SwFltStackEntry& rEntry, SwDoc* pDoc, +static bool MakePoint(const SwFltStackEntry& rEntry, SwDoc* pDoc, SwPaM& rRegion) { // the anchor is the Pam's Point. It's modified when inserting // text, etc.; therefore it is kept on the stack. Only the // attribute's format needs to be set. rRegion.DeleteMark(); - rRegion.GetPoint()->nNode = rEntry.m_aMkPos.m_nNode.GetIndex() + 1; + + sal_uLong nMk = rEntry.m_aMkPos.m_nNode.GetIndex() + 1; + const SwNodes& rMkNodes = rEntry.m_aMkPos.m_nNode.GetNodes(); + if (nMk >= rMkNodes.Count()) + return false; + + rRegion.GetPoint()->nNode = nMk; SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, true); rRegion.GetPoint()->nContent.Assign(pCNd, rEntry.m_aMkPos.m_nCntnt); + return true; } // MakeBookRegionOrPoint() behaves like MakeRegionOrPoint, except that // it adheres to certain restrictions on bookmarks in tables (cannot // span more than one cell) -static void MakeBookRegionOrPoint(const SwFltStackEntry& rEntry, SwDoc* pDoc, +static bool MakeBookRegionOrPoint(const SwFltStackEntry& rEntry, SwDoc* pDoc, SwPaM& rRegion, bool bCheck ) { - if (rEntry.MakeRegion(pDoc, rRegion, bCheck )){ + if (rEntry.MakeRegion(pDoc, rRegion, bCheck )) + { // sal_Bool b1 = rNds[rRegion.GetPoint()->nNode]->FindTableNode() != 0; if (rRegion.GetPoint()->nNode.GetNode().FindTableBoxStartNode() != rRegion.GetMark()->nNode.GetNode().FindTableBoxStartNode()) @@ -445,9 +453,9 @@ static void MakeBookRegionOrPoint(const SwFltStackEntry& rEntry, SwDoc* pDoc, rRegion.Exchange(); // invalid range rRegion.DeleteMark(); // -> both to mark } - }else{ - MakePoint(rEntry, pDoc, rRegion); + return true; } + return MakePoint(rEntry, pDoc, rRegion); } // IterateNumrulePiece() looks for the first range valid for Numrules @@ -596,8 +604,10 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, break; case RES_FLTR_ANNOTATIONMARK: { - MakeBookRegionOrPoint(rEntry, pDoc, aRegion, true); - pDoc->getIDocumentMarkAccess()->makeAnnotationMark(aRegion, OUString()); + if (MakeBookRegionOrPoint(rEntry, pDoc, aRegion, true)) + pDoc->getIDocumentMarkAccess()->makeAnnotationMark(aRegion, OUString()); + else + SAL_WARN("sw", "failed to make book region or point"); } break; case RES_FLTR_TOX:
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits