> -----Original Message----- > From: Martin Sebor [mailto:[EMAIL PROTECTED] > Sent: Friday, May 25, 2007 4:17 AM > To: [email protected] > Subject: Re: [PATCH] RE: [jira] Created: (STDCXX-427) SIGSEGV > in istringstream::str() > > Farid Zaripov wrote: > >> -----Original Message----- > >> From: Martin Sebor (JIRA) [mailto:[EMAIL PROTECTED] > >> Sent: Thursday, May 24, 2007 1:14 AM > >> To: [email protected] > >> Subject: [jira] Created: (STDCXX-427) SIGSEGV in > istringstream::str() > >> > > The bug also reproduced on MSVC. The proposed patch below: > > Thanks for looking into it! > > I'm not sure your proposed patch is correct or necessary > (although I'm not saying the original code is correct either). > In fact, I'm not sure the other overload of str(), i.e., the > one that sets the string buffer, is correct either and I > suspect that might be the root of the problem. > The function should assert(this->_C_is_valid()) as a postcondition > (and the overload below should do the same as a precondition) to > verify that the buffer is in a stable and consistent state. > Let's see if the assertion passes first before considering > this patch further.
The basic_stringbuf<>::str (const char_type *, _RWSTD_SIZE_T) have the assertions at begin and at end (sstream.cc line 72 and 167), and both assertions passes. The bug is in that len calculated as highmark - pbase(), but pbase() == 0 when buffer opened only in input mode. The begin of the buffer is always this->_C_buffer with any openmode. So len = highmark - _C_buffer is correct, I think. Farid.
