Modify

Ticket #4858 (closed Bugs: fixed)

Opened 3 years ago

Last modified 3 years ago

Documentation error - Responsefile example code can crash

Reported by: boost@… 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

Attachments

Change History

comment:1 Changed 3 years ago by marshall

(In [67030]) Doc fix; refs #4858

comment:2 Changed 3 years ago by marshall

  • Status changed from new to closed
  • Resolution set to fixed

(In [67034]) Merge doc patches to release; fixes #3992, fixes #4858

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.