[Bug libstdc++/13624] New: Unsafe delimiter in ostream_iterator
jlquinn at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Jan 9 04:35:00 GMT 2004
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
More information about the Gcc-bugs
mailing list