[webp] producing I/O exception instead of hard assertion on opening malformed images

GitOrigin-RevId: a354881c15d75a66bba661e6dab040a9815b0dfe
This commit is contained in:
Roman Shevchenko
2023-10-06 14:28:42 +02:00
committed by intellij-monorepo-bot
parent e6eb00eedc
commit 5308f61b0e

View File

@@ -206,9 +206,7 @@ public final class WebpImageReaderSpi extends ImageReaderSpi {
@Override
public @NotNull BufferedImage read(int imageIndex, ImageReadParam param) throws IOException {
loadInfoIfNeeded();
if (myError == 0) {
throw new IOException(UNABLE_TO_READ_WEBP_IMAGE);
}
if (myError == 0) throw new IOException(UNABLE_TO_READ_WEBP_IMAGE);
assert myInputBytes != null;
byte[] argb = libwebp.WebPDecodeARGB(myInputBytes, myInputBytes.length, myWidthOut, myHeightOut);
@SuppressWarnings("UndesirableClassUsage")
@@ -216,7 +214,7 @@ public final class WebpImageReaderSpi extends ImageReaderSpi {
// Copy the bytes read above to the image's data buffer.
final int[] a = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
IntBuffer intBuf = ByteBuffer.wrap(argb).asIntBuffer();
assert a.length == intBuf.remaining();
if (a.length != intBuf.remaining()) throw new IOException(UNABLE_TO_READ_WEBP_IMAGE);
intBuf.get(a);
return bi;
}