This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Bug/Memory Leak in <strstream>
- To: seel at mpi-sb dot mpg dot de
- Subject: Re: Bug/Memory Leak in <strstream>
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Wed, 26 Jan 2000 09:56:22 +0100
- CC: gcc-bugs at gcc dot gnu dot org
- References: <388D7235.736EC06@mpi-sb.mpg.de>
> While purifying one of my programs I found a leak in <strstream>.
Thanks for your bug report. This is not a bug in gcc, but in your
code. A strstream object freezes its contents when you perform
.str(). So you either need to release the result of .str() yourself,
or you need to unfreeze the stream:
#include <strstream>
int main()
{
int i;
std::ostrstream OS;
OS << "123" << '\0';
std::istrstream IS(OS.str());
IS >> i;
std::cout << i << std::endl;
OS.freeze(0);
return 0;
}
Hope this helps,
Martin