Cppcheck Dangerous iterator usage after erase()-method

julien2412 serval2412 at yahoo.fr
Sat Sep 15 11:08:34 PDT 2012


Hello,

Cppcheck reported this:
[sw/source/core/text/blink.cxx:183]: (error) Dangerous iterator usage after
erase()-method.

Here are the lines:
    178 void SwBlink::FrmDelete( const SwRootFrm* pRoot )
    179 {
    180     for( SwBlinkList::iterator it = aList.begin(); it !=
aList.end(); )
    181     {
    182         if( pRoot == (*it).GetRootFrm() )
    183             aList.erase( it );
    184         else
    185             ++it;
    186     }
    187 }

I must recognize, I don't understand how can it work above all if we go  in
the "if" since there's no increment.

Any idea?

Julien



--
View this message in context: http://nabble.documentfoundation.org/Cppcheck-Dangerous-iterator-usage-after-erase-method-tp4007715.html
Sent from the Dev mailing list archive at Nabble.com.


More information about the LibreOffice mailing list