sw/source/uibase/uno/unotxdoc.cxx |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

New commits:
commit d1c302789b46bcc007b2733772342b5b8e2942ef
Author:     Andras Timar <[email protected]>
AuthorDate: Mon Mar 2 10:47:16 2026 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Tue Mar 3 09:30:05 2026 +0100

    Fix SIGSEGV in SwXTextDocument LOKit methods with null m_pDocShell
    
    When document load fails, m_pDocShell is null and LOKit methods like
    getParts() called from documentStatus crash dereferencing it. Add null
    checks to getParts() and other LOKit methods missing them, matching
    the pattern of existing fixes in setClipboard(), getViewRenderState(),
    initializeForTiledRendering() and getPostIts().
    
    Change-Id: I4e38928ff171435d80623190696c76f9fc455c80
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200785
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 4ce2e4d87a3b..d8d499a3e0e1 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3326,6 +3326,9 @@ void SwXTextDocument::paintTile( VirtualDevice &rDevice,
 
 Size SwXTextDocument::getDocumentSize()
 {
+    if (!m_pDocShell)
+        return Size();
+
     SwViewShell* pViewShell = m_pDocShell->GetWrtShell();
     if (!pViewShell)
     {
@@ -3342,6 +3345,9 @@ void SwXTextDocument::setPart(int nPart, bool 
/*bAllowChangeFocus*/)
 {
     SolarMutexGuard aGuard;
 
+    if (!m_pDocShell)
+        return;
+
     SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
     if (!pWrtShell)
         return;
@@ -3353,6 +3359,9 @@ int SwXTextDocument::getParts()
 {
     SolarMutexGuard aGuard;
 
+    if (!m_pDocShell)
+        return 0;
+
     SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
     if (!pWrtShell)
         return 0;
@@ -3364,6 +3373,9 @@ OUString SwXTextDocument::getPartPageRectangles()
 {
     SolarMutexGuard aGuard;
 
+    if (!m_pDocShell)
+        return OUString();
+
     SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
     if (!pWrtShell)
         return OUString();
@@ -3390,6 +3402,9 @@ bool SwXTextDocument::isMimeTypeSupported()
 {
     SolarMutexGuard aGuard;
 
+    if (!m_pDocShell)
+        return false;
+
     SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
     if (!pWrtShell)
         return false;
@@ -3407,6 +3422,9 @@ bool SwXTextDocument::isMimeTypeSupported()
 
 void SwXTextDocument::setClientVisibleArea(const tools::Rectangle& rRectangle)
 {
+    if (!m_pDocShell)
+        return;
+
     if (SwView* pView = m_pDocShell->GetView())
     {
         // set the PgUp/PgDown offset
@@ -3449,6 +3467,9 @@ PointerStyle SwXTextDocument::getPointer()
 {
     SolarMutexGuard aGuard;
 
+    if (!m_pDocShell)
+        return PointerStyle::Arrow;
+
     SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
     if (!pWrtShell)
         return PointerStyle::Arrow;
@@ -3779,6 +3800,9 @@ int SwXTextDocument::getPart()
 {
     SolarMutexGuard aGuard;
 
+    if (!m_pDocShell)
+        return 0;
+
     SwView* pView = m_pDocShell->GetView();
     if (!pView)
         return 0;
@@ -3801,6 +3825,8 @@ OUString SwXTextDocument::getPartHash(int nPart)
 VclPtr<vcl::Window> SwXTextDocument::getDocWindow()
 {
     SolarMutexGuard aGuard;
+    if (!m_pDocShell)
+        return {};
     SwView* pView = m_pDocShell->GetView();
     if (!pView)
         return {};

Reply via email to