diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-09-12 21:01:41 +0200 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2012-09-21 12:11:56 +0000 |
commit | 04e34c9876c25be047c1b26c489d4185bacc54b5 (patch) | |
tree | 7d1d4cfdd483aee5cf94ee8fea9b6762dc39f83e | |
parent | 9b1ba36bce25cf5abd41835d5d4c156893e8eca6 (diff) |
fdo#42450: fix crash in SwXTextSection::attach:
Inserting the section can fail if the given text range is not valid.
Change-Id: Ib6ba3b02dd581dce08b646b841354073caf894b2
(cherry picked from commit 5bc6c7b2e170a35914d7cd07347c77a9c9d23664
and commit 2940a697dce2292e9c5b118feb8ec4159e3606fa)
Reviewed-on: https://gerrit.libreoffice.org/602
Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
Tested-by: Miklos Vajna <vmiklos@suse.cz>
(cherry picked from commit 525127d5b605bf34a8ff0b71f4b169fa7b72c435)
Reviewed-on: https://gerrit.libreoffice.org/607
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r-- | sw/source/core/unocore/unosect.cxx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 338c37666217..9e3ba6b86483 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -400,6 +400,14 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) SwSection *const pRet = pDoc->InsertSwSection( aPam, aSect, 0, aSet.Count() ? &aSet : 0 ); + if (!pRet) // fdo#42450 text range could parially overlap existing section + { + // shouldn't have created an undo object yet + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL ); + throw lang::IllegalArgumentException( + "SwXTextSection::attach(): invalid TextRange", + static_cast< ::cppu::OWeakObject*>(this), 0); + } pRet->GetFmt()->Add(m_pImpl.get()); pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); |