WaE: C6011 Dereferencing NULL pointer warnings

Change-Id: I396bada76e47f5bccca8296e844822a564b1ea0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167196
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara 2024-05-06 11:29:17 +01:00
parent 39ca990a6e
commit 42e38e671c
8 changed files with 16 additions and 12 deletions

View file

@ -65,7 +65,7 @@ void OSQLAnalyzer::bindParameterRow(OValueRefRow const & _pRow)
void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,std::vector< OSQLParseNode*>& _rParaNodes)
{
DBG_ASSERT(pParseNode != nullptr,"OResultSet: internal error: invalid ParseNode");
assert(pParseNode && "OResultSet: internal error: invalid ParseNode");
// found parameter Name-Rule?
if (SQL_ISRULE(pParseNode,parameter))

View file

@ -576,7 +576,7 @@ void OStatement_Base::GetAssignValues()
OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Error in Parse Tree");
OSQLParseNode * pAssignmentCommalist = m_pParseTree->getChild(3);
OSL_ENSURE(pAssignmentCommalist != nullptr,"OResultSet: pAssignmentCommalist == NULL");
assert(pAssignmentCommalist && "OResultSet: pAssignmentCommalist == NULL");
OSL_ENSURE(SQL_ISRULE(pAssignmentCommalist,assignment_commalist),"OResultSet: Error in Parse Tree");
OSL_ENSURE(pAssignmentCommalist->count() > 0,"OResultSet: pAssignmentCommalist->count() <= 0");
@ -585,15 +585,15 @@ void OStatement_Base::GetAssignValues()
for (size_t i = 0; i < pAssignmentCommalist->count(); i++)
{
OSQLParseNode * pAssignment = pAssignmentCommalist->getChild(i);
OSL_ENSURE(pAssignment != nullptr,"OResultSet: pAssignment == NULL");
assert(pAssignment && "OResultSet: pAssignment == NULL");
OSL_ENSURE(SQL_ISRULE(pAssignment,assignment),"OResultSet: Error in Parse Tree");
OSL_ENSURE(pAssignment->count() == 3,"OResultSet: pAssignment->count() != 3");
OSQLParseNode * pCol = pAssignment->getChild(0);
OSL_ENSURE(pCol != nullptr,"OResultSet: pCol == NULL");
assert(pCol && "OResultSet: pCol == NULL");
OSQLParseNode * pComp = pAssignment->getChild(1);
OSL_ENSURE(pComp != nullptr,"OResultSet: pComp == NULL");
assert(pComp && "OResultSet: pComp == NULL");
OSL_ENSURE(pComp->getNodeType() == SQLNodeType::Equal,"OResultSet: pComp->getNodeType() != SQLNodeType::Comparison");
if (pComp->getTokenValue().toChar() != '=')
{
@ -614,7 +614,7 @@ void OStatement_Base::ParseAssignValues(const std::vector< OUString>& aColumnNam
OSL_ENSURE(o3tl::make_unsigned(nIndex) <= aColumnNameList.size(),"SdbFileCursor::ParseAssignValues: nIndex > aColumnNameList.GetTokenCount()");
OUString aColumnName(aColumnNameList[nIndex]);
OSL_ENSURE(aColumnName.getLength() > 0,"OResultSet: Column-Name not found");
OSL_ENSURE(pRow_Value_Constructor_Elem != nullptr,"OResultSet: pRow_Value_Constructor_Elem must not be NULL!");
assert(pRow_Value_Constructor_Elem != nullptr && "OResultSet: pRow_Value_Constructor_Elem must not be NULL!");
if (pRow_Value_Constructor_Elem->getNodeType() == SQLNodeType::String ||
pRow_Value_Constructor_Elem->getNodeType() == SQLNodeType::IntNum ||

View file

@ -75,7 +75,7 @@ void OPredicateCompiler::start(OSQLParseNode const * pSQLParseNode)
DBG_ASSERT(pSQLParseNode->count() >= 4,"OFILECursor: Error in Parse Tree");
OSQLParseNode * pTableExp = pSQLParseNode->getChild(3);
DBG_ASSERT(pTableExp != nullptr,"Error in Parse Tree");
assert(pTableExp && "Error in Parse Tree");
DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp)," Error in Parse Tree");
DBG_ASSERT(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"Error in Parse Tree");
@ -546,7 +546,7 @@ bool OPredicateInterpreter::evaluate(OCodeList& rCodeList)
m_aStack.pop();
DBG_ASSERT(m_aStack.empty(), "Stack error");
DBG_ASSERT(pOperand, "Stack error");
assert(pOperand && "Stack error");
const bool bResult = pOperand->isValid();
if (typeid(OOperandResult) == typeid(*pOperand))
@ -572,7 +572,7 @@ void OPredicateInterpreter::evaluateSelection(OCodeList& rCodeList, ORowSetValue
m_aStack.pop();
DBG_ASSERT(m_aStack.empty(), "Stack error");
DBG_ASSERT(pOperand, "Stack error");
assert(pOperand && "Stack error");
(*_rVal) = pOperand->getValue();
if (typeid(OOperandResult) == typeid(*pOperand))

View file

@ -77,6 +77,7 @@ void OPreparedStatement::ensurePrepared()
if (!m_pInSqlda)
{
m_pInSqlda = static_cast<XSQLDA*>(calloc(1, XSQLDA_LENGTH(10)));
assert(m_pInSqlda && "Don't handle OOM conditions");
m_pInSqlda->version = SQLDA_VERSION1;
m_pInSqlda->sqln = 10;
}
@ -97,6 +98,7 @@ void OPreparedStatement::ensurePrepared()
short nItems = m_pInSqlda->sqld;
free(m_pInSqlda);
m_pInSqlda = static_cast<XSQLDA*>(calloc(1, XSQLDA_LENGTH(nItems)));
assert(m_pInSqlda && "Don't handle OOM conditions");
m_pInSqlda->version = SQLDA_VERSION1;
m_pInSqlda->sqln = nItems;
aErr = isc_dsql_describe_bind(m_statusVector,

View file

@ -131,6 +131,7 @@ void OStatementCommonBase::prepareAndDescribeStatement(std::u16string_view sql,
if (!pOutSqlda)
{
pOutSqlda = static_cast<XSQLDA*>(calloc(1, XSQLDA_LENGTH(10)));
assert(pOutSqlda && "Don't handle OOM conditions");
pOutSqlda->version = SQLDA_VERSION1;
pOutSqlda->sqln = 10;
}
@ -169,6 +170,7 @@ void OStatementCommonBase::prepareAndDescribeStatement(std::u16string_view sql,
int n = pOutSqlda->sqld;
free(pOutSqlda);
pOutSqlda = static_cast<XSQLDA*>(calloc(1, XSQLDA_LENGTH(n)));
assert(pOutSqlda && "Don't handle OOM conditions");
pOutSqlda->version = SQLDA_VERSION1;
pOutSqlda->sqln = n;
aErr = isc_dsql_describe(m_statusVector,

View file

@ -40,7 +40,7 @@ ODatabaseMetaData::ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection* _pCon
,m_pConnection(_pCon)
,m_bUseCatalog(true)
{
OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
assert(m_pConnection && "ODatabaseMetaData::ODatabaseMetaData: No connection set!");
if(!m_pConnection->isCatalogUsed())
{
osl_atomic_increment( &m_refCount );

View file

@ -154,7 +154,7 @@ void bufferQuoteAnyConstant( OUStringBuffer & buf, const Any &val, ConnectionSet
static void ibufferQuoteIdentifier( OUStringBuffer & buf, std::u16string_view toQuote, ConnectionSettings *settings )
{
OSL_ENSURE(settings, "pgsql-sdbc: bufferQuoteIdentifier got NULL settings");
assert(settings && "pgsql-sdbc: bufferQuoteIdentifier got NULL settings");
OString y = iOUStringToOString( toQuote, settings );
char *cstr = PQescapeIdentifier(settings->pConnection, y.getStr(), y.getLength());

View file

@ -61,7 +61,7 @@ namespace connectivity
rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; }
const OUString& getURL() const { return m_sURL; }
void setURL(const OUString& _rsUrl) { m_sURL = _rsUrl; }
void throwGenericSQLException(TranslateId pErrorResourceId, const css::uno::Reference< css::uno::XInterface>& _xContext);
[[noreturn]] void throwGenericSQLException(TranslateId pErrorResourceId, const css::uno::Reference< css::uno::XInterface>& _xContext);
const SharedResources& getResources() const { return m_aResources;}
void setConnectionInfo(const css::uno::Sequence< css::beans::PropertyValue >& _aInfo) { m_aConnectionInfo = _aInfo; }