sw/source/filter/indexing/IndexingExport.cxx |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 10863c2ef3f140844abe4e58f83a421086ac664b
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Sep 12 23:25:12 2021 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Sep 13 03:10:06 2021 +0200

    indexing: prevent crash when creting the indexing XML
    
    The pOutlinerParagraphObject can be null, so need to check for
    that or the applciation can crash.
    
    Change-Id: Icf771bb9ae2c344ed04e8ec27a22390a272ad725
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121998
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 2f755ae4bf69951c29ec64c5df500687051e4ee3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122017
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/source/filter/indexing/IndexingExport.cxx 
b/sw/source/filter/indexing/IndexingExport.cxx
index 6c436f9f6180..6974fe599e58 100644
--- a/sw/source/filter/indexing/IndexingExport.cxx
+++ b/sw/source/filter/indexing/IndexingExport.cxx
@@ -123,17 +123,20 @@ public:
         if (pTextObject)
         {
             OutlinerParaObject* pOutlinerParagraphObject = 
pTextObject->GetOutlinerParaObject();
-            const EditTextObject& aEdit = 
pOutlinerParagraphObject->GetTextObject();
-            for (sal_Int32 nParagraph = 0; nParagraph < 
aEdit.GetParagraphCount(); ++nParagraph)
+            if (pOutlinerParagraphObject)
             {
-                OUString sText = aEdit.GetText(nParagraph);
-
-                m_rXmlWriter.startElement("paragraph");
-                m_rXmlWriter.attribute("index", nParagraph);
-                m_rXmlWriter.attribute("node_type", OString("common"));
-                m_rXmlWriter.attribute("object_name", pObject->GetName());
-                m_rXmlWriter.content(sText);
-                m_rXmlWriter.endElement();
+                const EditTextObject& aEdit = 
pOutlinerParagraphObject->GetTextObject();
+                for (sal_Int32 nParagraph = 0; nParagraph < 
aEdit.GetParagraphCount(); ++nParagraph)
+                {
+                    OUString sText = aEdit.GetText(nParagraph);
+
+                    m_rXmlWriter.startElement("paragraph");
+                    m_rXmlWriter.attribute("index", nParagraph);
+                    m_rXmlWriter.attribute("node_type", OString("common"));
+                    m_rXmlWriter.attribute("object_name", pObject->GetName());
+                    m_rXmlWriter.content(sText);
+                    m_rXmlWriter.endElement();
+                }
             }
         }
     }

Reply via email to