I got this program that worked well 2 weeks ago, I didn’t change any parts on where it now crashes.
For example, take this snippet : (assuming is is a valid istream and contains <tag>)
std::string Str;
char c;
for ( ; is >> c; )
{
std::cout << c << std::flush;
Str += c;
}
Output :
<
then crash.
I’m using Windows and mingGW, the crash is a window saying that my program has encoutner an error, Windows is trying to fix it…
But this is not all, it crashes the same with Str = c; or when initilizing : std::string Str ("op");
30 minutes after I have found this error, I got another one (previous to the initial one) on a line :
osstr.write((char *) Word, 16);
Where osstr is a valid ostringstream and Word is a filled unsigned char *
Edit:
The problem is probably NOT in the code. Because a simple call to the string constructor crashes.
std::string Str ("") works
std::string Str ("str"); crash
Right, sorry for incomplete information, but I just couldn’t give you the whole code.
The problem came from a buffer overflow far before the code above that didn’t crash.