diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-11-07 16:38:12 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-11-08 11:38:20 +0100 |
commit | 532f8f94dfc3c4ea1c00027368644df4da929779 (patch) | |
tree | a34bc8cec1c4c151a2b978f2f63c3320f2df4c98 | |
parent | 16dbce55ca951019229b92c0607930a3e559ec16 (diff) |
SwXFlatParagraph: check some positions before blindly using them
Change-Id: Ic33b7a4b87120bd01b56737ded0411651306098d
-rw-r--r-- | sw/source/core/unocore/unoflatpara.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index d25d6fffbdac..fc7710e962ff 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -251,6 +251,11 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c SwTextNode *const pOldTextNode = GetTextNode(); + if (nPos < 0 || pOldTextNode->Len() < nPos || nLen < 0 || static_cast<sal_uInt32>(pOldTextNode->Len()) < static_cast<sal_uInt32>(nPos) + nLen) + { + throw lang::IllegalArgumentException(); + } + SwPaM aPaM( *GetTextNode(), nPos, *GetTextNode(), nPos+nLen ); UnoActionContext aAction( GetTextNode()->GetDoc() ); @@ -279,6 +284,11 @@ void SAL_CALL SwXFlatParagraph::changeAttributes(::sal_Int32 nPos, ::sal_Int32 n if (!GetTextNode()) return; + if (nPos < 0 || GetTextNode()->Len() < nPos || nLen < 0 || static_cast<sal_uInt32>(GetTextNode()->Len()) < static_cast<sal_uInt32>(nPos) + nLen) + { + throw lang::IllegalArgumentException(); + } + SwPaM aPaM( *GetTextNode(), nPos, *GetTextNode(), nPos+nLen ); UnoActionContext aAction( GetTextNode()->GetDoc() ); |