sw/source/core/text/EnhancedPDFExportHelper.cxx |   30 ++++++++++++------------
 1 file changed, 16 insertions(+), 14 deletions(-)

New commits:
commit 33f5ab817202b06af061ee3866f3b4013bdbcd27
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Sep 15 21:13:14 2025 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue Sep 16 13:38:28 2025 +0200

    cid#1665431 Dereference null return value
    
    Change-Id: Icba6d8bdc8f07c8125c7c4784f93c19dd7d1bd7f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191000
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 6591bec892cd..f11700bc01d3 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1446,21 +1446,23 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
                 const SwSection* pSection =
                         static_cast<const 
SwSectionFrame*>(pFrame)->GetSection();
 
-                // open all parent sections, so that the SEs of sections
-                // are nested in the same way as their SwSectionNodes
-                std::vector<SwSection const*> parents;
-                // iterate only *direct* parents - do not leave table cell!
-                for (SwSectionNode const* pSectionNode{pSection->GetFormat()
-                        
->GetSectionNode()->StartOfSectionNode()->GetSectionNode()};
-                    pSectionNode != nullptr;
-                    pSectionNode = 
pSectionNode->StartOfSectionNode()->GetSectionNode())
+                if (SwSectionNode const* pFormatSectionNode = 
pSection->GetFormat()->GetSectionNode())
                 {
-                    parents.push_back(&pSectionNode->GetSection());
-                }
-                for (auto it = parents.rbegin(); it != parents.rend(); ++it)
-                {
-                    // key is the SwSection - see lcl_GetKeyFromFrame()
-                    OpenTagImpl(*it);
+                    // open all parent sections, so that the SEs of sections
+                    // are nested in the same way as their SwSectionNodes
+                    std::vector<SwSection const*> parents;
+                    // iterate only *direct* parents - do not leave table cell!
+                    for (SwSectionNode const* 
pSectionNode{pFormatSectionNode->StartOfSectionNode()->GetSectionNode()};
+                        pSectionNode != nullptr;
+                        pSectionNode = 
pSectionNode->StartOfSectionNode()->GetSectionNode())
+                    {
+                        parents.push_back(&pSectionNode->GetSection());
+                    }
+                    for (auto it = parents.rbegin(); it != parents.rend(); 
++it)
+                    {
+                        // key is the SwSection - see lcl_GetKeyFromFrame()
+                        OpenTagImpl(*it);
+                    }
                 }
 
                 FrameTagSet& 
rFrameTagSet(mpPDFExtOutDevData->GetSwPDFState()->m_FrameTagSet);

Reply via email to