[REVIEW-3-6] fix for fdo#52351, remove conditional formatting if all its cells are removed
Stephan Bergmann
sbergman at redhat.com
Mon Aug 6 08:21:37 PDT 2012
On 08/06/2012 04:08 PM, Kohei Yoshida wrote:
> Regarding
>
> iterator itr = begin();
> while(itr != end())
> {
> if(itr->GetRange().empty())
> maConditionalFormats.erase(itr++);
> else
> ++itr;
> }
>
> that erase line causes an undefined behavior, and subtle, hard-to-find
> bug later. maConditionalFormats is a boost::ptr_set which uses
> std::set in its implementation. The std::set's erase call invalidates
> the iterator of the element that has just been deleted, and that line
> increments the iterator after it's been invalidated.
No, the line first increments itr, then calls erase (on the old itr value).
Stephan
More information about the LibreOffice
mailing list