summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-04-30 21:45:06 +0200
committerMichael Stahl <mstahl@redhat.com>2014-05-03 00:49:14 +0200
commit45cb8e3d1eb8a5eb20f8fd9c61ba78e5546bd15e (patch)
tree2fa31feca61f73b0b3b6ad44df6a1e4f4e621242
parente06131e96629eee4e94eba1da7242380716e8e88 (diff)
sw: hypothetical crashes if last node is not SwTxtNode
Change-Id: I16c476ae83d01ea23891af36fd4bcca4e8992228
-rw-r--r--sw/source/core/doc/docglos.cxx3
-rw-r--r--sw/source/core/edit/acorrect.cxx3
-rw-r--r--sw/source/core/edit/edglss.cxx11
-rw-r--r--sw/source/core/uibase/uno/unoatxt.cxx2
-rw-r--r--sw/source/filter/ww8/ww8glsy.cxx2
5 files changed, 13 insertions, 8 deletions
diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx
index 4b2538ef9333..c706208ec21b 100644
--- a/sw/source/core/doc/docglos.cxx
+++ b/sw/source/core/doc/docglos.cxx
@@ -140,7 +140,8 @@ bool SwDoc::InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry,
// till the nodes array's end
aCpyPam.GetPoint()->nNode = pGDoc->GetNodes().GetEndOfContent().GetIndex()-1;
pCntntNd = aCpyPam.GetCntntNode();
- aCpyPam.GetPoint()->nContent.Assign( pCntntNd, pCntntNd->Len() );
+ aCpyPam.GetPoint()->nContent.Assign(
+ pCntntNd, (pCntntNd) ? pCntntNd->Len() : 0 );
GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL );
SwPaM *_pStartCrsr = &rPaM, *__pStartCrsr = _pStartCrsr;
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index d21ba64ce960..20ee723f6eb9 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -369,7 +369,8 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
// then until the end of the Nodes Array
aCpyPam.GetPoint()->nNode.Assign( pAutoDoc->GetNodes().GetEndOfContent(), -1 );
pCntntNd = aCpyPam.GetCntntNode();
- aCpyPam.GetPoint()->nContent.Assign( pCntntNd, pCntntNd->Len() );
+ aCpyPam.GetPoint()->nContent.Assign(
+ pCntntNd, (pCntntNd) ? pCntntNd->Len() : 0);
SwDontExpandItem aExpItem;
aExpItem.SaveDontExpandItems( *aPam.GetPoint() );
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 6e23c62bf82f..7a17737e4b6c 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -138,7 +138,8 @@ sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock,
// then until the end of the nodes array
aCpyPam.GetPoint()->nNode = pMyDoc->GetNodes().GetEndOfContent().GetIndex()-1;
pCntntNd = aCpyPam.GetCntntNode();
- aCpyPam.GetPoint()->nContent.Assign( pCntntNd, pCntntNd->Len() );
+ aCpyPam.GetPoint()->nContent.Assign(
+ pCntntNd, (pCntntNd) ? pCntntNd->Len() : 0);
aStt = pGDoc->GetNodes().GetEndOfExtras();
pCntntNd = pGDoc->GetNodes().GoNext( &aStt );
@@ -160,8 +161,9 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
SwNodes& rNds = pInsDoc->GetNodes();
SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 );
- SwCntntNode * pNd = aIdx.GetNode().GetCntntNode();
- SwPosition aPos( aIdx, SwIndex( pNd, pNd->Len() ));
+ SwCntntNode *const pContentNode = aIdx.GetNode().GetCntntNode();
+ SwPosition aPos( aIdx,
+ SwIndex(pContentNode, (pContentNode) ? pContentNode->Len() : 0));
// Should the index be reset to start?
if( pSttNd )
@@ -216,7 +218,8 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
if( !PCURCRSR->HasMark() )
{
- if( 0 != (pNd = PCURCRSR->GetCntntNode()) &&
+ SwCntntNode *const pNd = PCURCRSR->GetCntntNode();
+ if (0 != pNd &&
( bColSel || !pNd->GetTxtNode() ) )
{
PCURCRSR->SetMark();
diff --git a/sw/source/core/uibase/uno/unoatxt.cxx b/sw/source/core/uibase/uno/unoatxt.cxx
index 438e250da043..4c31e13c16d1 100644
--- a/sw/source/core/uibase/uno/unoatxt.cxx
+++ b/sw/source/core/uibase/uno/unoatxt.cxx
@@ -325,7 +325,7 @@ static bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTe
SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 );
SwCntntNode * pNd = aIdx.GetNode().GetCntntNode();
- SwPosition aPos( aIdx, SwIndex( pNd, pNd->Len() ));
+ SwPosition aPos(aIdx, SwIndex(pNd, (pNd) ? pNd->Len() : 0));
bool bRet = false;
pInsDoc->LockExpFlds();
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index 64a4e3cd2870..1ed667ca0694 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -167,7 +167,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks,
SwNodeIndex aIdx( pGlDoc->GetNodes().GetEndOfContent(),
-1 );
pCNd = aIdx.GetNode().GetCntntNode();
- SwPosition aPos( aIdx, SwIndex( pCNd, pCNd->Len() ));
+ SwPosition aPos(aIdx, SwIndex(pCNd, (pCNd) ? pCNd->Len() : 0));
pD->CopyRange( aPam, aPos, false );
rBlocks.PutDoc();
}