From: Vadim Zeitlin Date: Mon, 11 Feb 2008 20:23:29 +0000 (+0000) Subject: update m_lastcount correctly in wxBufferedInputStream::Read() when using the buffer... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6c91ea6f898a595a27686f2f1dd4cdb633a9eb16 update m_lastcount correctly in wxBufferedInputStream::Read() when using the buffer associated with another stream and not created by this one git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51662 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/stream.cpp b/src/common/stream.cpp index c612f4835b..d26e307163 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -1248,12 +1248,15 @@ wxInputStream& wxBufferedInputStream::Read(void *buf, size_t size) size -= m_lastcount; buf = (char *)buf + m_lastcount; - // the call to wxStreamBuffer::Read() below will reset our m_lastcount, - // so save it + // the call to wxStreamBuffer::Read() below may reset our m_lastcount + // (but it also may not do it if the buffer is associated to another + // existing stream and wasn't created by us), so save it size_t countOld = m_lastcount; - m_i_streambuf->Read(buf, size); + // the new count of the bytes read is the count of bytes read this time + m_lastcount = m_i_streambuf->Read(buf, size); + // plus those we had read before m_lastcount += countOld; }