This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/13624] New: Unsafe delimiter in ostream_iterator


An ostream_iterator constructed with a stream delimiter will break if the string
is destroyed since the class just stores a pointer to the constructor argument.
 I.e.

char *x = new char[4];
strcpy(x, "ugh");
ostream_iterator<int> it(cout, x);
delete[] x;
*it = 5;

A copy needs to be made for safety.  Present in 3.2, 3.3 as well.

-- 
           Summary: Unsafe delimiter in ostream_iterator
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jlquinn at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13624


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]