summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2012-09-06 10:56:14 +0000
committerHerbert Dürr <hdu@apache.org>2012-09-06 10:56:14 +0000
commitb2c0501949d6ce13685d716e1ad58b3265829b26 (patch)
tree3d87143d35ec3ec007e7c514ce0f335747fb5fbe /sw
parent68e5157012bc54ad4ce9bcd644cc163d5662ff67 (diff)
#i119714# prevent crash in SwXTextSection::attach()
As SwDoc::InsertSwSection() can and does return a NULL SwSection pointer callees must be protected. Found-By: Du Jing
Notes
Notes: prefer: 5bc6c7b2e170a35914d7cd07347c77a9c9d23664
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/docnode/ndsect.cxx6
-rw-r--r--sw/source/core/unocore/unosect.cxx33
2 files changed, 18 insertions, 21 deletions
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 239740c4eb49..53ebcaba487a 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -448,8 +448,7 @@ sal_uInt16 SwDoc::IsInsRegionAvailable( const SwPaM& rRange,
}
else if( !pSectNd && pEndSectNd )
{
- // versuche eine umschliessende Section zu erzeugen
- // Aber, nur wenn das Ende am Section Ende liegt!
+ // try to create a section enclosing it if the end is at the section end
nRet = 0;
if( pEnd->nContent.GetIndex() == pCNd->Len() )
{
@@ -475,8 +474,7 @@ sal_uInt16 SwDoc::IsInsRegionAvailable( const SwPaM& rRange,
}
else if( pSectNd && !pEndSectNd )
{
- // versuche eine umschliessende Section zu erzeugen
- // Aber, nur wenn der Start am Section Anfang liegt!
+ // try to create a section enclosing it if the start is at the section start
nRet = 0;
if( !pStt->nContent.GetIndex() )
{
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index 2b5dbc67adcf..8deff0e26627 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -430,29 +430,28 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
SwSection *const pRet =
pDoc->InsertSwSection( aPam, aSect, 0, aSet.Count() ? &aSet : 0 );
- pRet->GetFmt()->Add(m_pImpl.get());
- pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this));
-
- // #97450# XML import must hide sections depending on their old
- // condition status
- if (m_pImpl->m_pProps->m_sCondition.getLength() != 0)
+ if( pRet )
{
- pRet->SetCondHidden(m_pImpl->m_pProps->m_bCondHidden);
- }
+ pRet->GetFmt()->Add(m_pImpl.get());
+ pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this));
- // set update type if DDE link (and connect, if necessary)
- if (m_pImpl->m_pProps->m_bDDE)
- {
- if (! pRet->IsConnected())
+ // XML import must hide sections depending on their old condition status
+ if (m_pImpl->m_pProps->m_sCondition.getLength() != 0)
+ pRet->SetCondHidden(m_pImpl->m_pProps->m_bCondHidden);
+
+ // set update type if DDE link (and connect, if necessary)
+ if (m_pImpl->m_pProps->m_bDDE)
{
- pRet->CreateLink(CREATE_CONNECT);
+ if (! pRet->IsConnected())
+ pRet->CreateLink(CREATE_CONNECT);
+
+ pRet->SetUpdateType( static_cast< sal_uInt16 >(
+ (m_pImpl->m_pProps->m_bUpdateType) ?
+ sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) );
}
- pRet->SetUpdateType( static_cast< sal_uInt16 >(
- (m_pImpl->m_pProps->m_bUpdateType) ?
- sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) );
}
- // Undo-Klammerung hier beenden
+ // end section undo here
pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL );
m_pImpl->m_pProps.reset();
m_pImpl->m_bIsDescriptor = false;