X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fzlib-helper.c;h=9dcebc7e967d6b04e9d8780c6cf7807e51bac228;hb=afd9c96b3f5c432a8d337dc134a59e09fa405a9a;hp=ff6bbb18dd96d64038ab82dbab9fbd96c86e0a6b;hpb=ec0063b889aaa1790c383cd84a25754d66a82476;p=mono.git diff --git a/support/zlib-helper.c b/support/zlib-helper.c index ff6bbb18dd9..9dcebc7e967 100644 --- a/support/zlib-helper.c +++ b/support/zlib-helper.c @@ -17,6 +17,10 @@ #include #include +#ifndef MONO_API +#define MONO_API +#endif + #ifndef TRUE #define FALSE 0 #define TRUE 1 @@ -190,21 +194,22 @@ ReadZStream (ZStream *stream, guchar *buffer, gint length) while (zs->avail_out > 0) { if (zs->avail_in == 0) { n = stream->func (stream->buffer, BUFFER_SIZE, stream->gchandle); + n = n < 0 ? 0 : n; stream->total_in += n; - if (n <= 0) { - stream->eof = TRUE; - } zs->next_in = stream->buffer; - zs->avail_in = n < 0 ? 0 : n; + zs->avail_in = n; } - if (zs->avail_in == 0 && (zs->total_in == 0 || stream->total_in == zs->total_in)) - return Z_STREAM_END; + if (zs->avail_in == 0 && zs->total_in == 0) + return 0; status = inflate (stream->stream, Z_SYNC_FLUSH); if (status == Z_STREAM_END) { stream->eof = TRUE; break; + } else if (status == Z_BUF_ERROR && stream->total_in == zs->total_in) { + stream->eof = TRUE; + break; } else if (status != Z_OK) { return status; }