connectivity/source/commontools/TColumnsHelper.cxx | 4 -- connectivity/source/parse/internalnode.cxx | 11 ++--- connectivity/source/parse/sqliterator.cxx | 26 +++++++------- connectivity/source/parse/sqlnode.cxx | 12 +++--- i18npool/source/indexentry/indexentrysupplier_default.cxx | 1 scripting/source/stringresource/stringresource.cxx | 6 ++- ucb/source/ucp/file/filtask.cxx | 2 - 7 files changed, 30 insertions(+), 32 deletions(-)
New commits: commit e6981b99ac5447f917287f5102a0a18b4972871e Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed May 1 08:33:07 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed May 1 10:50:11 2024 +0200 WaE: C6011 Dereferencing NULL pointer warnings Change-Id: Ic2c2e227a50994298377485e9e807cd9142cc386 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166949 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/connectivity/source/commontools/TColumnsHelper.cxx b/connectivity/source/commontools/TColumnsHelper.cxx index aeb8b48a649a..b346b5a23236 100644 --- a/connectivity/source/commontools/TColumnsHelper.cxx +++ b/connectivity/source/commontools/TColumnsHelper.cxx @@ -64,10 +64,9 @@ OColumnsHelper::~OColumnsHelper() { } - sdbcx::ObjectType OColumnsHelper::createObject(const OUString& _rName) { - OSL_ENSURE(m_pTable,"NO Table set. Error!"); + assert(m_pTable && "NO Table set. Error!"); Reference<XConnection> xConnection = m_pTable->getConnection(); if ( !m_pImpl ) @@ -142,7 +141,6 @@ sdbcx::ObjectType OColumnsHelper::createObject(const OUString& _rName) return xRet; } - void OColumnsHelper::impl_refresh() { if ( m_pTable ) diff --git a/connectivity/source/parse/internalnode.cxx b/connectivity/source/parse/internalnode.cxx index 1906ad3d4625..9b7849345556 100644 --- a/connectivity/source/parse/internalnode.cxx +++ b/connectivity/source/parse/internalnode.cxx @@ -28,7 +28,7 @@ OSQLInternalNode::OSQLInternalNode(const char* pNewValue, sal_uInt32 nNodeID) : OSQLParseNode(pNewValue,eNodeType,nNodeID) { - OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); + assert(OSQLParser::s_pGarbageCollector && "Collector not initialized"); (*OSQLParser::s_pGarbageCollector)->push_back(this); } @@ -38,26 +38,23 @@ OSQLInternalNode::OSQLInternalNode(std::string_view NewValue, sal_uInt32 nNodeID) :OSQLParseNode(NewValue,eNodeType,nNodeID) { - OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); + assert(OSQLParser::s_pGarbageCollector && "Collector not initialized"); (*OSQLParser::s_pGarbageCollector)->push_back(this); } - OSQLInternalNode::OSQLInternalNode(const OUString &NewValue, SQLNodeType eNodeType, sal_uInt32 nNodeID) :OSQLParseNode(NewValue,eNodeType,nNodeID) { - OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); + assert(OSQLParser::s_pGarbageCollector && "Collector not initialized"); (*OSQLParser::s_pGarbageCollector)->push_back(this); } - OSQLInternalNode::~OSQLInternalNode() { // remove the node from the garbage list - - OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized"); + assert(OSQLParser::s_pGarbageCollector && "Collector not initialized"); (*OSQLParser::s_pGarbageCollector)->erase(this); } diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index f190d5dbfc97..3171507bcc67 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -610,7 +610,7 @@ void OSQLParseTreeIterator::getSelect_statement(OSQLTables& _rTables,const OSQLP } OSQLParseNode * pTableRefCommalist = pSelect->getChild(3)->getChild(0)->getChild(1); - OSL_ENSURE(pTableRefCommalist != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableRefCommalist != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableRefCommalist,table_ref_commalist),"OSQLParseTreeIterator: error in parse tree!"); const OSQLParseNode* pTableName = nullptr; @@ -965,21 +965,21 @@ void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNo OSL_ENSURE(pSelectNode->count() >= 4,"OSQLParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = pSelectNode->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator:table_exp error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); sal_uInt32 nPos = ( _bOrder ? ORDER_BY_CHILD_POS : 2 ); OSQLParseNode * pOptByClause = pTableExp->getChild(nPos); - OSL_ENSURE(pOptByClause != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pOptByClause != nullptr && "OSQLParseTreeIterator: error in parse tree!"); if ( pOptByClause->count() == 0 ) return; OSL_ENSURE(pOptByClause->count() == 3,"OSQLParseTreeIterator: error in parse tree!"); OSQLParseNode * pOrderingSpecCommalist = pOptByClause->getChild(2); - OSL_ENSURE(pOrderingSpecCommalist != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pOrderingSpecCommalist != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(!_bOrder || SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OSQLParseTreeIterator:ordering_spec_commalist error in parse tree!"); OSL_ENSURE(pOrderingSpecCommalist->count() > 0,"OSQLParseTreeIterator: error in parse tree!"); @@ -989,7 +989,7 @@ void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNo for (sal_uInt32 i = 0; i < nCount; ++i) { OSQLParseNode* pColumnRef = pOrderingSpecCommalist->getChild(i); - OSL_ENSURE(pColumnRef != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pColumnRef != nullptr && "OSQLParseTreeIterator: error in parse tree!"); if ( _bOrder ) { OSL_ENSURE(SQL_ISRULE(pColumnRef,ordering_spec),"OSQLParseTreeIterator:ordering_spec error in parse tree!"); @@ -997,7 +997,7 @@ void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNo pColumnRef = pColumnRef->getChild(0); } - OSL_ENSURE(pColumnRef != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pColumnRef != nullptr && "OSQLParseTreeIterator: error in parse tree!"); aTableRange.clear(); sColumnName.clear(); if ( SQL_ISRULE(pColumnRef,column_ref) ) @@ -1123,7 +1123,7 @@ bool OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSele OSL_ENSURE(pSelectNode->count() >= 4,"OSQLParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = pSelectNode->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); @@ -1221,8 +1221,8 @@ void OSQLParseTreeIterator::traverseSearchCondition(OSQLParseNode const * pSearc OSQLParseNode * pNum_value_exp = pPart2->getChild(nCurrentPos); OSQLParseNode * pOptEscape = pPart2->getChild(nCurrentPos+1); - OSL_ENSURE(pNum_value_exp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pOptEscape != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pNum_value_exp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); + assert(pOptEscape != nullptr && "OSQLParseTreeIterator: error in parse tree!"); if (pOptEscape->count() != 0) { @@ -1803,7 +1803,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getWhereTree() const { OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = m_pParseTree->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); @@ -1844,7 +1844,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getOrderTree() const OSQLParseNode * pOrderClause = nullptr; OSL_ENSURE(pParseTree->count() == 4, "OSQLParseTreeIterator::getOrderTree: expected a SELECT, and a SELECT must have exactly four children"); OSQLParseNode * pTableExp = pParseTree->getChild(3); - OSL_ENSURE(pTableExp != nullptr, "OSQLParseTreeIterator::getOrderTree: got NULL table_exp"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator::getOrderTree: got NULL table_exp"); OSL_ENSURE(SQL_ISRULE(pTableExp, table_exp), "OSQLParseTreeIterator::getOrderTree: expected table_exp but got something else"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator::getOrderTree: table_exp doesn't have the expected number of children"); // tdf#141115 upgrade the above to an assert; @@ -1868,7 +1868,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getGroupByTree() const OSQLParseNode * pGroupClause = nullptr; OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = m_pParseTree->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); @@ -1889,7 +1889,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getHavingTree() const OSQLParseNode * pHavingClause = nullptr; OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!"); OSQLParseNode * pTableExp = m_pParseTree->getChild(3); - OSL_ENSURE(pTableExp != nullptr,"OSQLParseTreeIterator: error in parse tree!"); + assert(pTableExp != nullptr && "OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index ad8f6c9edeff..823813b3f0e0 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1676,10 +1676,9 @@ OSQLParseNode::~OSQLParseNode() { } - void OSQLParseNode::append(OSQLParseNode* pNewNode) { - OSL_ENSURE(pNewNode != nullptr, "OSQLParseNode: invalid NewSubTree"); + assert(pNewNode != nullptr && "OSQLParseNode: invalid NewSubTree"); OSL_ENSURE(pNewNode->getParent() == nullptr, "OSQLParseNode: Node is not an orphan"); OSL_ENSURE(std::none_of(m_aChildren.begin(), m_aChildren.end(), [&] (std::unique_ptr<OSQLParseNode> const & r) { return r.get() == pNewNode; }), @@ -2707,15 +2706,16 @@ OSQLParseNode::Rule OSQLParseNode::getKnownRuleID() const OUString OSQLParseNode::getTableRange(const OSQLParseNode* _pTableRef) { - OSL_ENSURE(_pTableRef && _pTableRef->count() > 1 && _pTableRef->getKnownRuleID() == OSQLParseNode::table_ref,"Invalid node give, only table ref is allowed!"); + assert(_pTableRef); + OSL_ENSURE(_pTableRef->count() > 1 && _pTableRef->getKnownRuleID() == OSQLParseNode::table_ref,"Invalid node give, only table ref is allowed!"); const sal_uInt32 nCount = _pTableRef->count(); OUString sTableRange; if ( nCount == 2 || (nCount == 3 && !_pTableRef->getChild(0)->isToken()) ) { const OSQLParseNode* pNode = _pTableRef->getChild(nCount - (nCount == 2 ? 1 : 2)); - OSL_ENSURE(pNode && (pNode->getKnownRuleID() == OSQLParseNode::table_primary_as_range_column - || pNode->getKnownRuleID() == OSQLParseNode::range_variable) - ,"SQL grammar changed!"); + assert(pNode); + OSL_ENSURE(pNode->getKnownRuleID() == OSQLParseNode::table_primary_as_range_column || + pNode->getKnownRuleID() == OSQLParseNode::range_variable, "SQL grammar changed!"); if ( !pNode->isLeaf() ) sTableRange = pNode->getChild(1)->getTokenValue(); } // if ( nCount == 2 || nCount == 3 ) diff --git a/i18npool/source/indexentry/indexentrysupplier_default.cxx b/i18npool/source/indexentry/indexentrysupplier_default.cxx index 898214f8b1ae..f65ee2843857 100644 --- a/i18npool/source/indexentry/indexentrysupplier_default.cxx +++ b/i18npool/source/indexentry/indexentrysupplier_default.cxx @@ -96,6 +96,7 @@ void IndexTable::init(sal_Unicode start_, sal_Unicode end_, IndexKey const *keys start=start_; end=end_; table = static_cast<sal_uInt8*>(malloc((end-start+1)*sizeof(sal_uInt8))); + assert(table && "Don't handle OOM conditions"); for (sal_Unicode i = start; i <= end; i++) { sal_Int16 j; for (j = 0; j < key_count; j++) { diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index d568af7a1b47..7b5db938a08d 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -470,10 +470,12 @@ void StringResourceImpl::removeLocale( const Locale& locale ) } if( m_pCurrentLocaleItem == pRemoveItem ) { + assert(pFallbackItem); setCurrentLocale( pFallbackItem->m_locale, false/*FindClosestMatch*/ ); } if( m_pDefaultLocaleItem == pRemoveItem ) { + assert(pFallbackItem); setDefaultLocale( pFallbackItem->m_locale ); } } @@ -1568,8 +1570,8 @@ static OUString implGetNameScemeForLocaleItem( const LocaleItem* pLocaleItem ) static const char aUnder[] = "_"; - OSL_ENSURE( pLocaleItem, - "StringResourcePersistenceImpl::implGetNameScemeForLocaleItem(): pLocaleItem == NULL" ); + assert(pLocaleItem && + "StringResourcePersistenceImpl::implGetNameScemeForLocaleItem(): pLocaleItem == NULL"); Locale aLocale = pLocaleItem->m_locale; OUString aRetStr = aUnder + aLocale.Language; diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx index 930f952d0019..24530fecdfb9 100644 --- a/ucb/source/ucp/file/filtask.cxx +++ b/ucb/source/ucp/file/filtask.cxx @@ -1319,7 +1319,7 @@ bool getType( TaskManager & task, sal_Int32 id, OUString const & fileUrl, osl::DirectoryItem * item, osl::FileStatus::Type * type) { - OSL_ASSERT(item != nullptr && type != nullptr); + assert(item != nullptr && type != nullptr); osl::FileBase::RC err = osl::DirectoryItem::get(fileUrl, *item); if (err != osl::FileBase::E_None) { task.installError(id, TASKHANDLING_TRANSFER_BY_COPY_SOURCE, err);