[Libreoffice-commits] core.git: sw/source
Justin Luth
justin_luth at sil.org
Mon Mar 21 07:50:44 UTC 2016
sw/source/core/crsr/bookmrk.cxx | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
New commits:
commit feafa40e30505a1740272f2036441f1ca23cbfd6
Author: Justin Luth <justin_luth at sil.org>
Date: Mon Mar 21 08:41:19 2016 +0300
avoid null pointer crash during mail-merge
It is possible to have a null TextNode in a FieldMark when
copying bookmarks between documents. The logic was tweaked
to add a test preventing the exception.
Change-Id: Ifaf779b9adc4bb07584bf6362cfe9d32aef315bc
Reviewed-on: https://gerrit.libreoffice.org/23389
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index d494796..39d1a480 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -73,8 +73,9 @@ namespace
SwPosition rStart = pField->GetMarkStart();
SwTextNode const*const pStartTextNode = rStart.nNode.GetNode().GetTextNode();
- const sal_Unicode ch_start = ( rStart.nContent.GetIndex() >= pStartTextNode->GetText().getLength() ) ? 0 :
- pStartTextNode->GetText()[rStart.nContent.GetIndex()];
+ sal_Unicode ch_start = 0;
+ if( pStartTextNode && ( rStart.nContent.GetIndex() < pStartTextNode->GetText().getLength() ) )
+ ch_start = pStartTextNode->GetText()[rStart.nContent.GetIndex()];
if( ( ch_start != aStartMark ) && ( aEndMark != CH_TXT_ATR_FORMELEMENT ) )
{
SwPaM aStartPaM(rStart);
@@ -87,7 +88,9 @@ namespace
SwTextNode const*const pEndTextNode = rEnd.nNode.GetNode().GetTextNode();
const sal_Int32 nEndPos = ( rEnd == rStart || rEnd.nContent.GetIndex() == 0 ) ?
rEnd.nContent.GetIndex() : rEnd.nContent.GetIndex() - 1;
- const sal_Unicode ch_end = nEndPos >= pEndTextNode->GetText().getLength() ? 0 : pEndTextNode->GetText()[nEndPos];
+ sal_Unicode ch_end = 0;
+ if ( pEndTextNode && ( nEndPos < pEndTextNode->GetText().getLength() ) )
+ ch_end = pEndTextNode->GetText()[nEndPos];
if ( aEndMark && ( ch_end != aEndMark ) )
{
SwPaM aEndPaM(rEnd);
@@ -107,8 +110,9 @@ namespace
const SwPosition& rStart = pField->GetMarkStart();
SwTextNode const*const pStartTextNode = rStart.nNode.GetNode().GetTextNode();
- const sal_Unicode ch_start =
- pStartTextNode->GetText()[rStart.nContent.GetIndex()];
+ sal_Unicode ch_start = 0;
+ if( pStartTextNode )
+ ch_start = pStartTextNode->GetText()[rStart.nContent.GetIndex()];
if( ch_start == aStartMark )
{
@@ -122,7 +126,9 @@ namespace
const sal_Int32 nEndPos = ( rEnd == rStart || rEnd.nContent.GetIndex() == 0 )
? rEnd.nContent.GetIndex()
: rEnd.nContent.GetIndex() - 1;
- const sal_Unicode ch_end = pEndTextNode->GetText()[nEndPos];
+ sal_Unicode ch_end = 0;
+ if ( pEndTextNode )
+ ch_end = pEndTextNode->GetText()[nEndPos];
if ( ch_end == aEndMark )
{
SwPaM aEnd(rEnd, rEnd);
More information about the Libreoffice-commits
mailing list