]> git.saurik.com Git - wxWidgets.git/commitdiff
Check for end of buffer in wxMemoryInputStream::Peek.
authorMattia Barbon <mbarbon@cpan.org>
Wed, 5 Jan 2005 07:36:14 +0000 (07:36 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Wed, 5 Jan 2005 07:36:14 +0000 (07:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/mstream.cpp

index 5c4302a6407118f019b247056bd26af90c2a45cd..21cc9ee95c56ced529ec7f56a096ac453934afa7 100644 (file)
@@ -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