Skip to content

22.0-cppcheck-tauEvent

Shaun Roe requested to merge sroe/athena:22.0-cppcheck-tauEvent into master

Removing use-after-erase iterators highlighted below:

 void TauJet::CleanDetailsForAOD()
    {
        ElementLinkVector<TauDetailsContainer>::iterator idetail
            = m_tauDetails.begin();
        while(idetail != m_tauDetails.end()) {
            // counter
            const unsigned int i = idetail - m_tauDetails.begin();

            //Remove invalid details
            if (!(*idetail).isValid()) 	{ 
                m_tauDetails.erase(idetail);//<— Iterator 'idetail' used after element has been erased. [+]
                continue;
            }
            const TauDetails* detail =* m_tauDetails[i];
            //Remove 0 details
            if (detail==0) {
                m_tauDetails.erase(idetail);//<— Iterator 'idetail' used after element has been erased. [+]<--- Iterator 'idetail' used after element has been erased. [+]
                continue;
            }
            //Remove any extra detail
            if ( (dynamic_cast<const TauCommonExtraDetails*>(detail)!=0) ||
                    (dynamic_cast<const TauRecExtraDetails*>(detail)!=0) ||
                    (dynamic_cast<const Tau1P3PExtraDetails*>(detail)!=0) ) 
                m_tauDetails.erase(idetail);//<— Iterator 'idetail' used after element has been erased. [+]<--- Iterator 'idetail' used after element has been erased. [+]
            ++idetail;//<— Iterator 'idetail' used after element has been erased. [+]
        }
    }

Merge request reports

Loading