Bug 864339 - Fix "New Private Tab" crash when unzipping a bitmap resource. r=glandium

This commit is contained in:
Chris Peterson 2013-04-23 15:58:45 -07:00
parent 4e3a627727
commit b2c84d28fb

View File

@ -7,6 +7,8 @@ package org.mozilla.gecko.mozglue;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
public class NativeZip implements NativeReference {
private static final int DEFLATE = 8;
@ -67,9 +69,16 @@ public class NativeZip implements NativeReference {
private native InputStream _getInputStream(long obj, String path);
private InputStream createInputStream(ByteBuffer buffer, int compression) {
if (compression != STORE) {
throw new IllegalArgumentException("Got compression " + compression + ", but expected 0 (STORE)!");
if (compression != STORE && compression != DEFLATE) {
throw new IllegalArgumentException("Unexpected compression: " + compression);
}
return new ByteBufferInputStream(buffer, this);
InputStream input = new ByteBufferInputStream(buffer, this);
if (compression == DEFLATE) {
Inflater inflater = new Inflater(true);
input = new InflaterInputStream(input, inflater);
}
return input;
}
}