Bug 65796: License violation in PICT.java

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896887 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Axel Howind 2022-01-10 14:37:13 +00:00
parent 1533af4f1d
commit 78f7decf00

View File

@ -23,6 +23,7 @@ import java.awt.Dimension;
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.util.Arrays;
import java.util.zip.InflaterInputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
@ -99,7 +100,7 @@ public final class PICT extends Metafile {
out.write(chunk, 0, count);
// PICT zip-stream can be erroneous, so we clear the array to determine
// the maximum of read bytes, after the inflater crashed
bytefill(chunk, (byte) 0);
Arrays.fill(chunk, (byte) 0);
}
} catch (Exception e) {
int lastLen = chunk.length - 1;
@ -186,22 +187,4 @@ public final class PICT extends Metafile {
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for PICT");
}
}
/*
* initialize a smaller piece of the array and use the System.arraycopy
* call to fill in the rest of the array in an expanding binary fashion
*/
private static void bytefill(byte[] array, byte value) {
// http://stackoverflow.com/questions/9128737/fastest-way-to-set-all-values-of-an-array
int len = array.length;
if (len > 0){
array[0] = value;
}
for (int i = 1; i < len; i += i) {
System.arraycopy(array, 0, array, i, Math.min(len - i, i));
}
}
}