Re: [Boost-bugs] [Boost C++ Libraries] #5139: Initial Stream Position in Boost.Interprocess.Vectorstream

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5139: Initial Stream Position in Boost.Interprocess.Vectorstream
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-01-29 14:35:36


#5139: Initial Stream Position in Boost.Interprocess.Vectorstream
---------------------------------+------------------------------------------
  Reporter: charles@… | Owner: igaztanaga
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: interprocess
   Version: Boost 1.45.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------+------------------------------------------

Comment (by anonymous):

 I think the problem is with
 boost::interprocess::basic_vectorstream::seekoff.

 On line 284 of boost/interprocess/streams/vectorstream.hpp it reads:

 {{{
 #!div style="font-size: 80%"
 Code highlighting:
   {{{#!C++
       //Test for logic errors
       if(!in & !out)
          return pos_type(off_type(-1));
       else if((in && out) && (dir == std::ios_base::cur))
          return pos_type(off_type(-1));
       else if((in && (!(m_mode & std::ios_base::in) || this->gptr() ==
 0)) ||
                (out && (!(m_mode & std::ios_base::out) || this->pptr() ==
 0)))
          return pos_type(off_type(-1));
   }}}
 }}}

 This code doesn't account for the possibility that the internal vector is
 empty, and the user simply wants to get the current position (which should
 be 0.)

 A possible fix would be:

 {{{
 #!div style="font-size: 80%"
 Code highlighting:
   {{{#!C++
 //Test for logic errors
 if (!in & !out)
    return pos_type(off_type(-1));
 else if((in && out) && (dir == std::ios_base::cur))
    return pos_type(off_type(-1));
 else if( (in && (!(m_mode & std::ios_base::in))) || (out && (!(m_mode &
 std::ios_base::out))))
    return pos_type(off_type(-1));
 else if ((in && this->gptr() == 0) || (out && this->pptr() == 0))
    return off == 0 ? pos_type(off_type(0)) : pos_type(off_type(-1));
   }}}
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5139#comment:1>
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:05 UTC