From: Mattia Barbon Date: Wed, 5 Jan 2005 07:36:14 +0000 (+0000) Subject: Check for end of buffer in wxMemoryInputStream::Peek. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6c783b03a0e0953d98a444de69dcdc598fce1ed5 Check for end of buffer in wxMemoryInputStream::Peek. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/mstream.cpp b/src/common/mstream.cpp index 5c4302a640..21cc9ee95c 100644 --- a/src/common/mstream.cpp +++ b/src/common/mstream.cpp @@ -60,8 +60,15 @@ wxMemoryInputStream::~wxMemoryInputStream() char wxMemoryInputStream::Peek() { char *buf = (char *)m_i_streambuf->GetBufferStart(); + size_t pos = m_i_streambuf->GetIntPosition(); + if ( pos == m_length ) + { + m_lasterror = wxSTREAM_READ_ERROR; + + return 0; + } - return buf[m_i_streambuf->GetIntPosition()]; + return buf[pos]; } bool wxMemoryInputStream::Eof() const