From b012d206350f57bf4268d8cd8528c32647c6b933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 9 Dec 2024 17:34:00 +0000 Subject: [PATCH] cid#1636669 Dereference after null check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I56e9669058a79750f83bb99e682e25c3fea2a0bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178170 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sc/source/filter/xml/xmlexprt.cxx | 54 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 246a7fe8e3a1..e41e3ece60c4 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -5261,36 +5261,38 @@ void ScXMLExport::GetChangeTrackViewSettings(ScDocument& rDoc, uno::Sequence& rProps) { - if (GetModel().is()) + if (!GetModel().is()) + return; + + ScModelObj* pDocObj(comphelper::getFromUnoTunnel( GetModel() )); + if (!pDocObj) + return; + + SfxObjectShell* pEmbeddedObj = pDocObj->GetEmbeddedObject(); + if (pEmbeddedObj) { rProps.realloc(4); beans::PropertyValue* pProps(rProps.getArray()); - ScModelObj* pDocObj(comphelper::getFromUnoTunnel( GetModel() )); - if (pDocObj) - { - SfxObjectShell* pEmbeddedObj = pDocObj->GetEmbeddedObject(); - if (pEmbeddedObj) - { - tools::Rectangle aRect(pEmbeddedObj->GetVisArea()); - sal_uInt16 i(0); - pProps[i].Name = "VisibleAreaTop"; - pProps[i].Value <<= static_cast(aRect.Top()); - pProps[++i].Name = "VisibleAreaLeft"; - pProps[i].Value <<= static_cast(aRect.Left()); - pProps[++i].Name = "VisibleAreaWidth"; - pProps[i].Value <<= static_cast(aRect.getOpenWidth()); - pProps[++i].Name = "VisibleAreaHeight"; - pProps[i].Value <<= static_cast(aRect.getOpenHeight()); - } - } - ScDocument* pDoc = pDocObj->GetDocument(); - if (!pDoc) - { - SAL_WARN("sc", "no ScDocument!"); - return; - } - GetChangeTrackViewSettings(*pDoc, rProps); + + tools::Rectangle aRect(pEmbeddedObj->GetVisArea()); + sal_uInt16 i(0); + pProps[i].Name = "VisibleAreaTop"; + pProps[i].Value <<= static_cast(aRect.Top()); + pProps[++i].Name = "VisibleAreaLeft"; + pProps[i].Value <<= static_cast(aRect.Left()); + pProps[++i].Name = "VisibleAreaWidth"; + pProps[i].Value <<= static_cast(aRect.getOpenWidth()); + pProps[++i].Name = "VisibleAreaHeight"; + pProps[i].Value <<= static_cast(aRect.getOpenHeight()); } + + ScDocument* pDoc = pDocObj->GetDocument(); + if (!pDoc) + { + SAL_WARN("sc", "no ScDocument!"); + return; + } + GetChangeTrackViewSettings(*pDoc, rProps); } void ScXMLExport::GetConfigurationSettings(uno::Sequence& rProps)