[Boost-bugs] [Boost C++ Libraries] #9585: program_option::environment_iterator moves past terminating NULL pointer

Subject: [Boost-bugs] [Boost C++ Libraries] #9585: program_option::environment_iterator moves past terminating NULL pointer
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-17 17:07:26


#9585: program_option::environment_iterator moves past terminating NULL pointer
------------------------------+-----------------------------
 Reporter: abel@… | Owner: vladimir_prus
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: program_options
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
------------------------------+-----------------------------
 The get() method increments m_environment outside of the else scope:

         void get()
         {
             if (*m_environment == 0)

                 found_eof();

             else {

                 std::string s(*m_environment);

                 std::string::size_type n = s.find('=');

                 assert(n != s.npos);

                 value().first = s.substr(0, n);

                 value().second = s.substr(n+1);
             }

             ++m_environment;
         }

 This means the iterator will move past the terminating pointer. A simple
 fix seems to include the increment in the else's scope.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9585>
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:15 UTC