sd/source/core/drawdoc2.cxx |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit a2822e7e053a2ad72bd507e6fc802d5e1fe82777
Author:     Mohit Marathe <[email protected]>
AuthorDate: Mon Dec 15 15:08:43 2025 +0530
Commit:     Mohit Marathe <[email protected]>
CommitDate: Wed Dec 17 13:13:29 2025 +0100

    sd: add page count check in SdDrawDocument::connectPagePreviews
    
    return early if the document has only one non-canvas page
    
    Signed-off-by: Mohit Marathe <[email protected]>
    Change-Id: I79cb8277f5ed62a1f683c1c6a4b18844267dddf6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195651
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index c83e10bcd85a..df48c0231fe4 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -1777,7 +1777,8 @@ void SdDrawDocument::connectPagePreviews()
     if (!HasCanvasPage())
         return;
     SdrObjList* pObjList = mpCanvasPage.get();
-    std::vector<SdrPageObj*> aPageOrder(GetSdPageCount(PageKind::Standard) - 
1, nullptr);
+    sal_uInt16 nPageCount = GetSdPageCount(PageKind::Standard);
+    std::vector<SdrPageObj*> aPageOrder(nPageCount - 1, nullptr);
 
     SdrObjListIter aIter(pObjList, SdrIterMode::Flat);
     for (SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next())
@@ -1796,6 +1797,10 @@ void SdDrawDocument::connectPagePreviews()
         }
     }
 
+    // return if the document has only one non-canvas page
+    if (nPageCount == 2)
+        return;
+
     for (size_t i = 0; i < aPageOrder.size() - 1; i++)
     {
         SdrPageObj* pPageObj1 = aPageOrder[i];

Reply via email to