From 86d39afd85ed929dcfb8e1497680605cb095fc41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sun, 5 Jun 2022 14:44:35 +0100 Subject: [PATCH] cid#1504593 silence Dereference null return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and cid#1504597 Dereference null return value cid#1504595 Dereference null return value cid#1504666 Dereference null return value Change-Id: I6054120575fb2769633177c36eb41c6798c4c648 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135436 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- dbaccess/source/ui/dlg/dbadmin.cxx | 10 ++++++---- dbaccess/source/ui/dlg/dbwiz.cxx | 5 +++-- dbaccess/source/ui/dlg/dbwizsetup.cxx | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index 3b528ba0b070..c6ca46f75324 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -91,8 +91,9 @@ void ODbAdminDialog::impl_selectDataSource(const css::uno::Any& _aDataSourceName Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); impl_resetPages( xDatasource ); - const DbuTypeCollectionItem& rCollectionItem = dynamic_cast(*getOutputSet()->GetItem(DSID_TYPECOLLECTION)); - ::dbaccess::ODsnTypeCollection* pCollection = rCollectionItem.getCollection(); + const DbuTypeCollectionItem* pCollectionItem = dynamic_cast(getOutputSet()->GetItem(DSID_TYPECOLLECTION)); + assert(pCollectionItem && "must exist"); + ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); ::dbaccess::DATASOURCE_TYPE eType = pCollection->determineType(getDatasourceType(*getOutputSet())); // and insert the new ones @@ -177,8 +178,9 @@ void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasou // special case: MySQL Native does not have the generic "advanced" page - const DbuTypeCollectionItem& rCollectionItem = dynamic_cast(*getOutputSet()->GetItem(DSID_TYPECOLLECTION)); - ::dbaccess::ODsnTypeCollection* pCollection = rCollectionItem.getCollection(); + const DbuTypeCollectionItem* pCollectionItem = dynamic_cast(getOutputSet()->GetItem(DSID_TYPECOLLECTION)); + assert(pCollectionItem && "must exist"); + ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); if ( pCollection->determineType(getDatasourceType( *m_xExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE ) { OString sMySqlNative("mysqlnative"); diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx index 6f90f3e499d6..fa06535022e0 100644 --- a/dbaccess/source/ui/dlg/dbwiz.cxx +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -77,8 +77,9 @@ ODbTypeWizDialog::ODbTypeWizDialog(weld::Window* _pParent, SfxItemSet const * _p m_xFinish->set_help_id(HID_DBWIZ_FINISH); // no local resources needed anymore - const DbuTypeCollectionItem& rCollectionItem = dynamic_cast(*_pItems->GetItem(DSID_TYPECOLLECTION)); - m_pCollection = rCollectionItem.getCollection(); + const DbuTypeCollectionItem* pCollectionItem = dynamic_cast(_pItems->GetItem(DSID_TYPECOLLECTION)); + assert(pCollectionItem && "must exist"); + m_pCollection = pCollectionItem->getCollection(); ActivatePage(); setTitleBase(DBA_RES(STR_DATABASE_TYPE_CHANGE)); diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 2c3e8fb7bb36..f687740dd696 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -117,8 +117,9 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(weld::Window* _pParent { // no local resources needed anymore // extract the datasource type collection from the item set - const DbuTypeCollectionItem& rCollectionItem = dynamic_cast(*_pItems->GetItem(DSID_TYPECOLLECTION)); - m_pCollection = rCollectionItem.getCollection(); + const DbuTypeCollectionItem* pCollectionItem = dynamic_cast(_pItems->GetItem(DSID_TYPECOLLECTION)); + assert(pCollectionItem && "must exist"); + m_pCollection = pCollectionItem->getCollection(); assert(m_pCollection && "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !");