c++ - Why does calling std::stringstream's good() through a pointer lead to crashes? -


i having problems stringstream object. class has input stream member. checking if obj->istream , after thatn if obj->istream->good().

the stream exists call good() crashes. in visual studio 2005. clue?

how reset istream?

 if (soap->is) {     if (soap->is->good())        return soap->is->read(s, (std::streamsize)n).gcount();      return 0; } 

that code gsoap framework

 std::istringstream in_stream; in_stream.str("a buffer"); soap->is = &in_stream; 

the in_stream goes out of scope, belongs local stack, ->is->good() called outside function when in_stream no longer exists.

this indicates is member not point stringstream. might initialized garbage value when enclosing object instantiated.

if testing pointer being zero, make sure it's set 0 in constructor (and reset 0 if ever detach stream).


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -