This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/13624] New: Unsafe delimiter in ostream_iterator
- From: "jlquinn at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jan 2004 04:35:58 -0000
- Subject: [Bug libstdc++/13624] New: Unsafe delimiter in ostream_iterator
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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