summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Frijters <jeroen@sumatra.nl>2010-01-12 16:49:01 +0000
committerJeroen Frijters <jeroen@sumatra.nl>2010-01-12 16:49:01 +0000
commit7934156fac05ab9295651cba242605ded918554c (patch)
treefc0654fa777ad15b27fc655af52254fcd7a7efe8
parentac76723006a51a38f1489b4a1ee734cbb00859b4 (diff)
downloadclasspath-7934156fac05ab9295651cba242605ded918554c.tar.gz
2010-01-12 Jeroen Frijters <jeroen@frijters.net>
* java/util/zip/Inflater. java (inflate(byte[],int,int)): Fix for #41696.
-rw-r--r--ChangeLog4
-rw-r--r--java/util/zip/Inflater.java42
2 files changed, 21 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index a6930b10f..221c5c94a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-01-12 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/util/zip/Inflater. java (inflate(byte[],int,int)): Fix for #41696.
+
2009-11-18 Andrew Haley <aph@redhat.com>
* java/util/TreeMap.java (anonymous class.size()): Debogosify.
diff --git a/java/util/zip/Inflater.java b/java/util/zip/Inflater.java
index e3e555ab9..f529dc691 100644
--- a/java/util/zip/Inflater.java
+++ b/java/util/zip/Inflater.java
@@ -311,37 +311,29 @@ public class Inflater
*/
public int inflate (byte[] buf, int off, int len) throws DataFormatException
{
- /* Special case: len may be zero */
- if (len == 0)
- return 0;
/* Check for correct buff, off, len triple */
if (0 > off || off > off + len || off + len > buf.length)
throw new ArrayIndexOutOfBoundsException();
int count = 0;
- int more;
- do
+ for (;;)
{
- if (mode != DECODE_CHKSUM)
- {
- /* Don't give away any output, if we are waiting for the
- * checksum in the input stream.
- *
- * With this trick we have always:
- * needsInput() and not finished()
- * implies more output can be produced.
- */
- more = outputWindow.copyOutput(buf, off, len);
- adler.update(buf, off, more);
- off += more;
- count += more;
- totalOut += more;
- len -= more;
- if (len == 0)
- return count;
- }
+ if (outputWindow.getAvailable() == 0)
+ {
+ if (!decode())
+ break;
+ }
+ else if (len > 0)
+ {
+ int more = outputWindow.copyOutput(buf, off, len);
+ adler.update(buf, off, more);
+ off += more;
+ count += more;
+ totalOut += more;
+ len -= more;
+ }
+ else
+ break;
}
- while (decode() || (outputWindow.getAvailable() > 0
- && mode != DECODE_CHKSUM));
return count;
}