From 623abd5df5e6a9932fc2a00d8790f288f19c9182 Mon Sep 17 00:00:00 2001
From: Caolán McNamara <caolanm@redhat.com>
Date: Fri, 5 Feb 2021 09:18:28 +0000
Subject: cid#1472784 Dereference null return value
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: Ifb6dc31b00ea170923d8cdb636185275e6877ca2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110457
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
---
 sw/source/filter/ww8/docxsdrexport.cxx | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

(limited to 'sw')

diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 27116bceb349..98f7c2d98e28 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -795,15 +795,13 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
                 m_pImpl->getSerializer()->endElementNS(XML_wp, nWrapToken);
             }
         }
-        else
+        else if (SdrObject* pSdrObj = const_cast<SdrObject*>(pFrameFormat->FindRealSdrObject()))
         {
             // In this case we likely had an odt document to be exported to docx.
             // There is no grab-bag or something else so for a workaround,
             // let's export the geometry of the shape...
             // First get the UNO-shape
-            uno::Reference<drawing::XShape> xShape(
-                const_cast<SdrObject*>(pFrameFormat->FindRealSdrObject())->getUnoShape(),
-                uno::UNO_QUERY);
+            uno::Reference<drawing::XShape> xShape(pSdrObj->getUnoShape(), uno::UNO_QUERY);
 
             if (xShape && xShape->getShapeType() == u"com.sun.star.drawing.CustomShape")
             {
-- 
cgit