[Boost-bugs] [Boost C++ Libraries] #4858: Documentation error - Responsefile example code can crash

Subject: [Boost-bugs] [Boost C++ Libraries] #4858: Documentation error - Responsefile example code can crash
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-16 11:36:42


#4858: Documentation error - Responsefile example code can crash
------------------------------+---------------------------------------------
 Reporter: boost@… | Owner: vladimir_prus
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: program_options
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 Hello,[[BR]]
 in the example concerning Response Files the following code has an
 error:[[BR]]
 {{{
      tokenizer<char_separator<char> > tok(ss.str(), sep);
      vector<string> args;
      copy(tok.begin(), tok.end(), back_inserter(args));
 }}}
 ss.str() in line 1 is a temporary. tokenizer will not store a copy, just
 iterators, so when tok is used in line 3 it refers to an invalid
 string.[[BR]]
 [[BR]]
 Code should be changed to:[[BR]]
 {{{
      std::string ResponsefileContents( ss.str() );
      tokenizer<char_separator<char> > tok(ResponsefileContents, sep);
      vector<string> args;
      copy(tok.begin(), tok.end(), back_inserter(args));
 }}}

 Best regards[[BR]]
 Sönke

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