imcdonagh / image4j

The image4j library allows you to read and write certain image formats in 100% pure Java.
Other
78 stars 38 forks source link

Infinite loop in ICODecoder #1

Closed achernoprudov closed 8 years ago

achernoprudov commented 9 years ago

Hello. I have found an infinite loop if i try to decode ICO image from ByteArrayInputStream. When I put file in FileInputStream it is ok.

final File file = new File("/tmp/logo.ico");
final FileInputStream is = new FileInputStream(file);
List<BufferedImage> imageContainer = ICODecoder.read(is);

But when I try to decode image from ByteArrayInputStream in stucks in loop at net.sf.image4j.codec.ico.ICODecoder.readExt(ICODecoder.java:155).

final File file = new File("/tmp/logo.ico");
final FileInputStream fileInputStream = new FileInputStream(file);
final byte[] byteArray = IOUtils.toByteArray(fileInputStream);
final ByteArrayInputStream is = new ByteArrayInputStream(byteArray);
List<BufferedImage> imageContainer = ICODecoder.read(is);

Here is ICO file: https://mega.nz/#!ZwYzBKYC!O6Y4_jQH7SyYin2e5UYB-GIwxU2IShb0ylkOjUdUbIQ

Ph3n1x commented 9 years ago

I had the same problem but discovered, that I was using the version 0.7 from the maven repo. In version 0.7.1 the infinite loop is fixed. Sadly, that version is not uploaded to the maven repo...