From 777fd647dc188519b1d1067dc25b1386ca36d9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 4 Mar 2000 20:37:23 +0000 Subject: [PATCH] fixed couple of bugs in wxZlibInputStream -- mainly incorrect handling of underlaying stream errors and absolutely wrong bytes counting git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/zstream.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/zstream.cpp b/src/common/zstream.cpp index 24f763bf28..7ca4e3bac4 100644 --- a/src/common/zstream.cpp +++ b/src/common/zstream.cpp @@ -89,15 +89,19 @@ size_t wxZlibInputStream::OnSysRead(void *buffer, size_t size) m_inflate->next_in = m_z_buffer; m_inflate->avail_in = m_parent_i_stream->LastRead(); - if (m_parent_i_stream->LastError() != wxStream_NOERROR) - return (size - m_inflate->avail_in); + if (m_parent_i_stream->LastError() != wxStream_NOERROR && + m_parent_i_stream->LastError() != wxStream_EOF) + { + m_lasterror = m_parent_i_stream->LastError(); + return 0; // failed to read anything + } } err = inflate(m_inflate, Z_FINISH); if (err == Z_STREAM_END) - return (size - m_inflate->avail_in); + return (size - m_inflate->avail_out); } - return size-m_inflate->avail_in; + return size-m_inflate->avail_out; } //////////////////////