Re: [Boost-bugs] [Boost C++ Libraries] #3166: Possible Bug in Boost.Interprocess vectorstream

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3166: Possible Bug in Boost.Interprocess vectorstream
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-06-11 15:48:02


#3166: Possible Bug in Boost.Interprocess vectorstream
---------------------------------+------------------------------------------
  Reporter: chsalvia_at_[hidden] | Owner: igaztanaga
      Type: Bugs | Status: new
 Milestone: Boost 1.40.0 | Component: interprocess
   Version: Boost 1.39.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------+------------------------------------------

Comment(by chsalvia_at_[hidden]):

 Essentially, this bug happens because the vector stream class has a member
 function vector(), which returns a const reference to the internal vector.
 But, if the the vectorstream is an output stream, a call to vector() also
 resizes the vector:

 {{{
  //!Returns a const reference to the internal vector.
    //!Does not throw.
    const vector_type &vector() const
    {
       if (this->m_mode & std::ios_base::out){
          if (mp_high_water < base_t::pptr()){
             //Restore the vector's size if necessary
             mp_high_water = base_t::pptr();
          }
          m_vect.resize(mp_high_water - (m_vect.size() ? &m_vect[0] : 0));
          const_cast<basic_vectorbuf * const>(this)->initialize_pointers();
       }
       return m_vect;
    }
 }}}

 Before resizing, the mp_high_water mark is set to the current position in
 the output sequence if it is less than pptr(). But, if a previous call to
 basic_vectorbuf::seekoff sets the stream position to 0, then the
 mp_high_water mark will not be changed, and the vector will be incorrectly
 resized.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3166#comment:3>
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:00 UTC