< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java

Print this page

        

*** 1357,1374 **** is = new InflaterInputStream(is, inf); is = new BufferedInputStream(is); this.pixelStream = new DataInputStream(is); /* ! * NB: the PNG spec declares that valid range for width * and height is [1, 2^31-1], so here we may fail to allocate * a buffer for destination image due to memory limitation. * ! * However, the recovery strategy for this case should be ! * defined on the level of application, so we will not ! * try to estimate the required amount of the memory and/or ! * handle OOM in any way. */ theImage = getDestination(param, getImageTypes(0), width, height); --- 1357,1373 ---- is = new InflaterInputStream(is, inf); is = new BufferedInputStream(is); this.pixelStream = new DataInputStream(is); /* ! * PNG spec declares that valid range for width * and height is [1, 2^31-1], so here we may fail to allocate * a buffer for destination image due to memory limitation. * ! * So if we get any OOM error at this stage we will wrap the ! * OOM error into an IIOException at higher level like ! * PNGImageReader.read(int, ImageReadParam). */ theImage = getDestination(param, getImageTypes(0), width, height);
*** 1669,1679 **** --- 1668,1687 ---- throws IIOException { if (imageIndex != 0) { throw new IndexOutOfBoundsException("imageIndex != 0!"); } + try { readImage(param); + } catch (IOException | + IllegalStateException | + IllegalArgumentException e) + { + throw e; + } catch (Throwable e) { + throw new IIOException("Caught exception during read: ", e); + } return theImage; } public void reset() { super.reset();
< prev index next >