Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cdm/core/src/main/java/ucar/nc2/filter/Deflate.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public byte[] encode(byte[] dataIn) throws IOException {

@Override
public byte[] decode(byte[] dataIn) throws IOException {
int len = Math.min(8 * dataIn.length, MAX_ARRAY_LEN);
long approxLen = (long) 8 * dataIn.length;
int len = approxLen > MAX_ARRAY_LEN ? MAX_ARRAY_LEN : (int) approxLen;
try (ByteArrayInputStream in = new ByteArrayInputStream(dataIn);
InflaterInputStream iis = new InflaterInputStream(in, new Inflater(), dataIn.length);
ByteArrayOutputStream os = new ByteArrayOutputStream(len)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ private byte[] inflate(byte[] compressed) throws IOException {

java.util.zip.InflaterInputStream inflatestream =
new java.util.zip.InflaterInputStream(in, inflater, inflatebuffersize);
int len = Math.min(8 * compressed.length, MAX_ARRAY_LEN);
long approxLen = (long) 8 * compressed.length;
int len = approxLen > MAX_ARRAY_LEN ? MAX_ARRAY_LEN : (int) approxLen;
ByteArrayOutputStream out = new ByteArrayOutputStream(len); // Fixes KXL-349288
IO.copyB(inflatestream, out, len);

Expand Down