sd/source/ui/unoidl/unomodel.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 8fb3913ea7bb3226f2e0d73a99d96cd420d97a7e
Author:     Miklos Vajna <[email protected]>
AuthorDate: Mon Oct 6 09:15:15 2025 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Oct 6 09:51:19 2025 +0200

    sd: fix crash in SdDrawPagesAccess::remove()
    
    Crashreport signature:
    
    > kit-1853625-1853625 2025-10-05 16:19:13.871457 +0000 [ kitbroker_02b ] 
SIG   Fatal signal received: SIGSEGV code: 1 for address: 0x100
    ...
    > program/libmergedlo.so
    >       SdrUndoPage::SdrUndoPage(SdrPage&)
    >               svx/source/svdraw/svdundo.cxx:1308
    > program/libmergedlo.so
    >       SdrUndoDelPage::SdrUndoDelPage(SdrPage&)
    >               svx/source/svdraw/svdundo.cxx:1383
    > program/libmergedlo.so
    >       std::_Head_base<0ul, SdrUndoAction*, 
false>::_Head_base<SdrUndoAction*&>(SdrUndoAction*&)
    >               /opt/rh/devtoolset-12/root/usr/include/c++/12/tuple:200
    > program/libsdlo.so
    >       
SdDrawPagesAccess::remove(com::sun::star::uno::Reference<com::sun::star::drawing::XDrawPage>
 const&)
    >               sd/source/ui/unoidl/unomodel.cxx:5181 (discriminator 4)
    
    and gdb on the coredump says:
    
    > #5  0x000070373442496a in SdDrawPagesAccess::remove (this=0x6caee6e0, 
xPage=...)
    >     at 
/home/collabora/jenkins/workspace/build_core_co-25.04_for_online_snapshot/sd/source/ui/unoidl/unomodel.cxx:5181
    > 5181                        
rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
    > (gdb) print pNotesPage
    > $5 = <optimized out>
    > (gdb) down
    > #4  SdrUndoFactory::CreateUndoDeletePage (this=<optimized out>, 
rPage=...) at 
/home/collabora/jenkins/workspace/build_core_co-25.04_for_online_snapshot/svx/source/svdraw/svdundo.cxx:1763
    > 1763        return std::make_unique<SdrUndoDelPage>(rPage);
    > (gdb) print &rPage
    > $6 = (SdrPage *) 0x0
    
    so check for the case when pNotesPage is nullptr.
    
    Change-Id: I1033d5196b329cb648fd27ac2633833a723f47a8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191938
    Reviewed-by: Michael Meeks <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 7889431fa898..caf855221649 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -5233,12 +5233,18 @@ void SAL_CALL SdDrawPagesAccess::remove( const 
uno::Reference< drawing::XDrawPag
                     // Add undo actions and delete the pages.  The order of 
adding
                     // the undo actions is important.
                     rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
-                    
rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
+                    if (pNotesPage)
+                    {
+                        
rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
+                    }
                     
rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
                 }
 
                 rDoc.RemovePage( nPage ); // the page
-                rDoc.RemovePage( nPage ); // the notes page
+                if (pNotesPage)
+                {
+                    rDoc.RemovePage( nPage ); // the notes page
+                }
 
                 if( bUndo )
                 {

Reply via email to