< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 372,382 **** } else { // Not tables only, so add original pos to the list imagePositions.add(savePos); // And set current image since we've read it now currentImage = 0; } ! if (seekForwardOnly) { Long pos = imagePositions.get(imagePositions.size()-1); iis.flushBefore(pos.longValue()); } tablesOnlyChecked = true; } --- 372,385 ---- } else { // Not tables only, so add original pos to the list imagePositions.add(savePos); // And set current image since we've read it now currentImage = 0; } ! // If the image positions list is empty as in the case of a tables-only ! // stream, then attempting to access the element at index ! // imagePositions.size() - 1 will cause an IndexOutOfBoundsException. ! if (seekForwardOnly && !imagePositions.isEmpty()) { Long pos = imagePositions.get(imagePositions.size()-1); iis.flushBefore(pos.longValue()); } tablesOnlyChecked = true; }
*** 490,499 **** --- 493,507 ---- throw new IndexOutOfBoundsException(); } if (!tablesOnlyChecked) { checkTablesOnly(); } + // If the image positions list is empty as in the case of a tables-only + // stream, then no image data can be read. + if (imagePositions.isEmpty()) { + throw new IIOException("No image data present to read"); + } if (imageIndex < imagePositions.size()) { iis.seek(imagePositions.get(imageIndex).longValue()); } else { // read to start of image, saving positions // First seek to the last position we already have, and skip the
< prev index next >