- int err;
-
- m_inflate.next_out = (unsigned char *)buffer;
- m_inflate.avail_out = size;
- m_eof = FALSE;
-
- while (m_inflate.avail_out > 0) {
- if (m_inflate.avail_in == 0) {
- wxFilterInputStream::Read(m_z_buffer, m_z_size);
- m_inflate.next_in = m_z_buffer;
- m_inflate.avail_in = wxFilterInputStream::LastRead();
- if (wxFilterInputStream::Eof()) {
- m_lastread = size - m_inflate.avail_out;
- return *this;
+ wxASSERT_MSG(m_inflate && m_z_buffer, wxT("Inflate stream not open"));
+
+ if (!m_inflate || !m_z_buffer)
+ m_lasterror = wxSTREAM_READ_ERROR;
+ if (!IsOk() || !size)
+ return 0;
+
+ int err = Z_OK;
+ m_inflate->next_out = (unsigned char *)buffer;
+ m_inflate->avail_out = size;
+
+ while (err == Z_OK && m_inflate->avail_out > 0) {
+ if (m_inflate->avail_in == 0) {
+ m_parent_i_stream->Read(m_z_buffer, m_z_size);
+ m_inflate->next_in = m_z_buffer;
+ m_inflate->avail_in = m_parent_i_stream->LastRead();
+
+ if (m_inflate->avail_in == 0) {
+ if (m_parent_i_stream->Eof())
+ wxLogError(_("Can't read inflate stream: unexpected EOF in underlying stream."));
+ m_lasterror = wxSTREAM_READ_ERROR;
+ break;