Farid Zaripov wrote:
  Below is the patch for fix STDCXX-515.

  ChangeLog:
  * sstream.cc (xsputn): Correct write position after growing the
buffer.

Why do we need to do it in xsputn()? Isn't str() supposed to keep
pptr() at the right offset after growing the buffer?

Martin


Index: sstream.cc
===================================================================
--- sstream.cc  (revision 564229)
+++ sstream.cc  (working copy)
@@ -185,10 +185,16 @@
         const _RWSTD_SIZE_T __bufsize =
             __n + (this->pptr () - this->pbase ());
+ // preserve current pptr() since str() would seek to end
+        const streamsize __cur = this->pptr () - this->pbase ();
+
         // grow the buffer if necessary to accommodate the whole
         // string plus the contents of the buffer up to pptr()
         str (this->_C_buffer, __bufsize);
+ // restore pptr()
+        this->pbump (__cur - (this->pptr () - this->pbase ()));
+
         _RWSTD_ASSERT (__n <= this->epptr () - this->pptr ());
     }
Farid.

Reply via email to