Opened 12 years ago
Closed 12 years ago
#4858 closed Bugs (fixed)
Documentation error - Responsefile example code can crash
| Reported by: | Owned by: | Vladimir Prus | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | program_options | 
| Version: | Boost 1.44.0 | Severity: | Problem | 
| Keywords: | Cc: | 
Description
Hello,
in the example concerning Response Files the following code has an error:
     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.
Code should be changed to:
     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
Sönke
Change History (2)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
  Note:
 See   TracTickets
 for help on using tickets.
    
(In [67030]) Doc fix; refs #4858