sc/source/ui/unoobj/chartuno.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
New commits: commit c4a8484bd6eb9c490b7af8c6aa1c25f05a3cfb5e Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun May 22 12:08:44 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun May 22 15:15:47 2022 +0200 cid#1504532 Dereference after null check Change-Id: I044e3bfec2af9d6379849b8ee6ce4ecbe637cc35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134727 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index ddfee69fbd1f..a4c9777a27c1 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -83,9 +83,10 @@ void ScChartsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) rtl::Reference<ScChartObj> ScChartsObj::GetObjectByIndex_Impl(tools::Long nIndex) const { - OUString aName; if ( pDocShell ) { + OUString aName; + ScDocument& rDoc = pDocShell->GetDocument(); ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer(); if (pDrawLayer) @@ -114,10 +115,11 @@ rtl::Reference<ScChartObj> ScChartsObj::GetObjectByIndex_Impl(tools::Long nIndex } } } + + if (!aName.isEmpty()) + return new ScChartObj( pDocShell, nTab, aName ); } - if (!aName.isEmpty()) - return new ScChartObj( pDocShell, nTab, aName ); return nullptr; }