From 6c783b03a0e0953d98a444de69dcdc598fce1ed5 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Wed, 5 Jan 2005 07:36:14 +0000 Subject: [PATCH] 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 --- src/common/mstream.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.50.0