Re: [Boost-bugs] [Boost C++ Libraries] #12578: Crash with boost::filesystem's directory_iterator and recursive_directory_iterator

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12578: Crash with boost::filesystem's directory_iterator and recursive_directory_iterator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-11-22 16:45:43


#12578: Crash with boost::filesystem's directory_iterator and
recursive_directory_iterator
-------------------------------+------------------------
  Reporter: anonymous | Owner: bemandawes
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: filesystem
   Version: Boost 1.61.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+------------------------

Comment (by mlimber@…):

 On further inspection, I have a proposed patch without doing any of the
 above. Instead, I change the {{{equal()}}} function of
 {{{directory_iterator}}} and {{{recursive_directory_iterator}}} to take
 account of what their shared owners may have done:
 {{{#!td
 Old
 }}}
 {{{#!td
 New
 }}}
 |----------------
 {{{#!td
   {{{#!cpp
     bool equal(const directory_iterator& rhs) const
       { return m_imp == rhs.m_imp; }
   }}}
 }}}
 {{{#!td
   {{{#!cpp
     bool equal(const directory_iterator& rhs) const
     {
       const bool is_lhs_valid = m_imp && m_imp->handle;
       const bool is_rhs_valid = rhs.m_imp && rhs.m_imp->handle;
       return (is_lhs_valid && is_rhs_valid && m_imp == rhs.m_imp)
         || (!is_lhs_valid && !is_rhs_valid);
     }
   }}}
 }}}
 |----------------
 {{{#!td
   {{{#!cpp
     bool equal(const recursive_directory_iterator& rhs) const
       { return m_imp == rhs.m_imp; }
   }}}
 }}}
 {{{#!td
   {{{#!cpp
     bool equal(const recursive_directory_iterator& rhs) const
     {
       const bool is_lhs_valid = m_imp && !m_imp->m_stack.empty();
       const bool is_rhs_valid = rhs.m_imp && !rhs.m_imp->m_stack.empty();
       return (is_lhs_valid && is_rhs_valid && m_imp == rhs.m_imp)
         || (!is_lhs_valid && !is_rhs_valid);
     }
   }}}
 }}}
 This allows my problematic programs above to detect if the iterator has
 been invalidated by comparing it against the empty iterator.

 Should I submit this as an official patch? (If so, what process should I
 go through to do so? I assume I'll have to add a unit test and validate
 existing tests as well.)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12578#comment:11>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC