- m_inflate.next_out = (unsigned char *)buffer;
- m_inflate.avail_out = size;
-
- while (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_parent_i_stream->Eof())
- return (size - m_inflate.avail_in);
+ m_inflate->next_out = (unsigned char *)buffer;
+ m_inflate->avail_out = size;
+
+ while (m_inflate->avail_out > 0) {
+ if (m_inflate->avail_in == 0) {
+
+ m_parent_i_stream->Read(m_z_buffer, wxMin(m_z_size, size));
+ m_inflate->next_in = m_z_buffer;
+ m_inflate->avail_in = m_parent_i_stream->LastRead();
+
+ wxStreamError err = m_parent_i_stream->GetLastError();
+ if ( err != wxSTREAM_NO_ERROR && err != wxSTREAM_EOF)
+ {
+ m_lasterror = err;
+ return 0; // failed to read anything
+ }
+
+ if ( m_inflate->avail_in == 0 )
+ {
+ // EOF
+ m_lasterror = wxSTREAM_EOF;
+ break;
+ }