natInflater.cc (inflate): Treat Z_BUF_ERROR as end-of-stream if avail_in is 0.
authorBryce McKinlay <bryce@albatross.co.nz>
Mon, 18 Dec 2000 01:00:23 +0000 (01:00 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Mon, 18 Dec 2000 01:00:23 +0000 (01:00 +0000)
        * java/util/zip/natInflater.cc (inflate): Treat Z_BUF_ERROR as
        end-of-stream if avail_in is 0.

From-SVN: r38338

libjava/ChangeLog
libjava/java/util/zip/natInflater.cc

index b19f7dcb163365e0ef11a859cebfc73124fb2d18..1bbb6faec236c1c1cda5189e2e37fd934e2de0d3 100644 (file)
@@ -1,3 +1,8 @@
+2000-12-18  Bryce McKinlay  <bryce@albatross.co.nz>
+
+       * java/util/zip/natInflater.cc (inflate): Treat Z_BUF_ERROR as 
+       end-of-stream if avail_in is 0.
+
 2000-12-17  Bryce McKinlay  <bryce@albatross.co.nz>
 
        * java/util/ArrayList.java (data): Declare transient.
index f3d258cdd59806443be792b12950f0849405f106..a9768fce77df1922de9585a944e63c800e4c5ba9 100644 (file)
@@ -106,6 +106,16 @@ java::util::zip::Inflater::inflate (jbyteArray buf, jint off, jint len)
 
   switch (::inflate (s, Z_SYNC_FLUSH))
     {
+    case Z_BUF_ERROR:
+      /* Using the no_header option, zlib requires an extra padding byte at the
+      end of the stream in order to successfully complete decompression (see
+      zlib/contrib/minizip/unzip.c). We don't do this, so can end up with a 
+      Z_BUF_ERROR at the end of a stream when zlib has completed inflation
+      and there's no more input. Thats not a problem. */
+      if (s->avail_in != 0)
+        throw new java::lang::InternalError;
+      // Fall through.
+      
     case Z_STREAM_END:
       is_finished = true;
       if (s->avail_out == (unsigned int) len)
@@ -125,11 +135,6 @@ java::util::zip::Inflater::inflate (jbyteArray buf, jint off, jint len)
       _Jv_Throw (new java::lang::OutOfMemoryError);
       break;
 
-    case Z_BUF_ERROR:
-      // FIXME?
-      _Jv_Throw (new java::lang::InternalError);
-      break;
-
     case Z_OK:
       break;
     }