I am having problems with a stringstream object. My class has an input stream as a member.
I am checking if obj->istream and after thatn if obj->istream->good().
The stream exists but the call to good() crashes. I am in Visual Studio 2005. Any clue?
How do I reset an istream?
if (soap->is) {
if (soap->is->good())
return soap->is->read(s, (std::streamsize)n).gcount();
return 0;
}
that code is from gsoap framework
std::istringstream in_stream;
in_stream.str("a buffer");
soap->is = &in_stream;
the in_stream goes out of scope, it belongs to a local stack, however the ->is->good()
is called outside that function when in_stream no longer exists.
This probably indicates that your
ismember does not point to astringstream. It might just be initialized to some garbage value when enclosing object is instantiated.If you are testing for pointer being zero, make sure it’s set to zero in the constructor (and reset to zero if you ever detach the stream).