starmath/source/unomodel.cxx |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 8dda6270f8b9af6fcfba2a3a935612ab5a81c247
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Oct 28 18:06:34 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat Oct 28 21:40:43 2023 +0200

    pPrinter may be nullptr
    
    E.g., calling storeToURL, generating a PDF, on an embedded formula.
    
    Change-Id: If74af90f9c3dfd54a328782ddecd0adf52b51a5a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158591
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 96e41599ddad..114fb29e43d7 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -958,8 +958,9 @@ uno::Sequence< beans::PropertyValue > SAL_CALL 
SmModel::getRenderer(
         throw RuntimeException();
 
     SmPrinterAccess aPrinterAccess( *pDocSh );
-    Printer *pPrinter = aPrinterAccess.GetPrinter();
-    Size    aPrtPaperSize ( pPrinter->GetPaperSize() );
+    Size aPrtPaperSize;
+    if (Printer *pPrinter = aPrinterAccess.GetPrinter())
+        aPrtPaperSize = pPrinter->GetPaperSize();
 
     // if paper size is 0 (usually if no 'real' printer is found),
     // guess the paper size
@@ -1029,11 +1030,16 @@ void SAL_CALL SmModel::render(
         return;
 
     SmPrinterAccess aPrinterAccess( *pDocSh );
-    Printer *pPrinter = aPrinterAccess.GetPrinter();
 
-    Size    aPrtPaperSize ( pPrinter->GetPaperSize() );
-    Size    aOutputSize   ( pPrinter->GetOutputSize() );
-    Point   aPrtPageOffset( pPrinter->GetPageOffset() );
+    Size aPrtPaperSize;
+    Size aOutputSize;
+    Point aPrtPageOffset;
+    if (Printer *pPrinter = aPrinterAccess.GetPrinter())
+    {
+        aPrtPaperSize = pPrinter->GetPaperSize();
+        aOutputSize = pPrinter->GetOutputSize();
+        aPrtPageOffset = pPrinter->GetPageOffset();
+    }
 
     // no real printer ??
     if (aPrtPaperSize.IsEmpty())

Reply via email to