Fix support of non-ASCII host names in System.Uri
[mono.git] / support / zlib-helper.c
index 23c662bf74d6f2e878d1802ba65a5810d72ce840..66b58663a5eb6beff5f7b34638bc2a01fbd65d3c 100644 (file)
@@ -103,12 +103,14 @@ CloseZStream (ZStream *zstream)
 
        status = 0;
        if (zstream->compress) {
-               do {
-                       status = deflate (zstream->stream, Z_FINISH);
-                       flush_status = Flush (zstream);
-               } while (status == Z_OK); /* We want Z_STREAM_END or error here here */
-               if (status == Z_STREAM_END)
-                       status = flush_status;
+               if (zstream->stream->total_in > 0) {
+                       do {
+                               status = deflate (zstream->stream, Z_FINISH);
+                               flush_status = Flush (zstream);
+                       } while (status == Z_OK); /* We want Z_STREAM_END or error here here */
+                       if (status == Z_STREAM_END)
+                               status = flush_status;
+               }
                deflateEnd (zstream->stream);
        } else {
                inflateEnd (zstream->stream);