From df3b8267416241cc64b3d2c7043ea6ca06294727 Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Mon, 21 Sep 2015 17:22:28 -0400 Subject: [PATCH] KDReportsXmlParser.cpp - crash check found by coverity in release mode --- src/KDReports/KDReportsXmlParser.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/KDReports/KDReportsXmlParser.cpp b/src/KDReports/KDReportsXmlParser.cpp index aab1513c..6b924ebe 100644 --- a/src/KDReports/KDReportsXmlParser.cpp +++ b/src/KDReports/KDReportsXmlParser.cpp @@ -527,12 +527,14 @@ bool KDReports::XmlParser::processNode( const QDomNode& node, KDReports::ReportB return false; } Q_ASSERT( builder ); - const QString type = element.attribute( QLatin1String( "type" ) ); - KDReports::VariableType vt = KDReports::XmlHelper::stringToVariableType( type ); - XmlElementHandlerV2* v2 = dynamic_cast(m_xmlElementHandler); - if (v2 && !v2->variable(vt, element)) - continue; - builder->addVariablePublic( vt ); + if ( builder ) { + const QString type = element.attribute( QLatin1String( "type" ) ); + KDReports::VariableType vt = KDReports::XmlHelper::stringToVariableType( type ); + XmlElementHandlerV2* v2 = dynamic_cast(m_xmlElementHandler); + if (v2 && !v2->variable(vt, element)) + continue; + builder->addVariablePublic( vt ); + } } else if ( name == QLatin1String( "page-break" ) ) { if ( m_xmlElementHandler && !m_xmlElementHandler->pageBreak( element ) ) continue; @@ -621,7 +623,7 @@ void KDReports::XmlParser::parseTabs( KDReports::ReportBuilder *builder, const Q tab.position = pos; tabs.append( tab ); } - } + } XmlElementHandlerV2* v2 = dynamic_cast(m_xmlElementHandler); if (!v2 || v2->tabs(tabs, tabsElement)) builder->setTabPositions( tabs );