Skip to content

Commit

Permalink
fix OOB exception due to assumption about bufferSize
Browse files Browse the repository at this point in the history
  • Loading branch information
saadsheralam committed Nov 18, 2024
1 parent 317db31 commit 09c3b48
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public class BlockCompressorStream extends CompressorStream {
public BlockCompressorStream(OutputStream out, Compressor compressor,
int bufferSize, int compressionOverhead) {
super(out, compressor, bufferSize);
MAX_INPUT_SIZE = bufferSize - compressionOverhead;
if (bufferSize - compressionOverhead >= 0) {
MAX_INPUT_SIZE = bufferSize - compressionOverhead;
} else {
throw new IllegalArgumentException("buffer size is less than compression overhead");
}
}

/**
Expand Down

0 comments on commit 09c3b48

Please sign in to comment.