You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by ma...@apache.org on 2009/08/20 21:33:48 UTC
svn commit: r806319 - in /xmlgraphics/commons/trunk:
src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java
test/images/corrupt-icc.png
test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java
Author: maxberger
Date: Thu Aug 20 19:33:48 2009
New Revision: 806319
URL: http://svn.apache.org/viewvc?rev=806319&view=rev
Log:
fixed bug #47708 Infinite loop on some PNGs with strange ICC
Added:
xmlgraphics/commons/trunk/test/images/corrupt-icc.png (with props)
Modified:
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java
xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java?rev=806319&r1=806318&r2=806319&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java Thu Aug 20 19:33:48 2009
@@ -292,12 +292,21 @@
decompresser.setInput(prof);
byte[] result = new byte[100];
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- while (!decompresser.finished()) {
+ boolean failed = false;
+ while ((!decompresser.finished()) && (!failed)) {
try {
int resultLength = decompresser.inflate(result);
bos.write(result, 0, resultLength);
+ if (resultLength == 0) {
+ // this means more data or an external dictionary is
+ // needed. Both of which are not available, so we
+ // fail.
+ log.debug("Failed to deflate ICC Profile");
+ failed = true;
+ }
} catch (DataFormatException e) {
log.debug("Failed to deflate ICC Profile", e);
+ failed = true;
}
}
decompresser.end();
Added: xmlgraphics/commons/trunk/test/images/corrupt-icc.png
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/images/corrupt-icc.png?rev=806319&view=auto
==============================================================================
Binary file - no diff available.
Propchange: xmlgraphics/commons/trunk/test/images/corrupt-icc.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java?rev=806319&r1=806318&r2=806319&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageLoaderTestCase.java Thu Aug 20 19:33:48 2009
@@ -215,6 +215,26 @@
}
}
+ public void testBrokenIccPng() throws Exception {
+ String uri = "corrupt-icc.png";
+
+ MyImageSessionContext sessionContext = createImageSessionContext();
+ ImageManager manager = imageContext.getImageManager();
+
+ ImageInfo info = manager.preloadImage(uri, sessionContext);
+ assertNotNull("ImageInfo must not be null", info);
+
+ Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, sessionContext);
+ assertNotNull("Image must not be null", img);
+ assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
+ ImageRendered imgRed = (ImageRendered)img;
+ assertNotNull(imgRed.getRenderedImage());
+ assertEquals(400, imgRed.getRenderedImage().getWidth());
+ assertEquals(300, imgRed.getRenderedImage().getHeight());
+
+ sessionContext.checkAllStreamsClosed();
+ }
+
private static class MyImageSessionContext extends MockImageSessionContext {
private List streams = new java.util.ArrayList();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org