diff --git a/components/formats-gpl/src/loci/formats/in/OIRReader.java b/components/formats-gpl/src/loci/formats/in/OIRReader.java index 0a6b85237ad..71e3a4ee3b7 100644 --- a/components/formats-gpl/src/loci/formats/in/OIRReader.java +++ b/components/formats-gpl/src/loci/formats/in/OIRReader.java @@ -687,7 +687,9 @@ private void readXMLBlock(String file, RandomAccessInputStream s) throws FormatE } // total block length could include multiple strings of XML int totalBlockLength = s.readInt(); + LOGGER.debug("total block length = {}", totalBlockLength); long end = s.getFilePointer() + totalBlockLength - 4; + LOGGER.debug("end = {}", end); s.skipBytes(4); while (s.getFilePointer() < end) { @@ -735,6 +737,9 @@ else if (xmlLength < 0 || xmlLength >= (s.length() - s.getFilePointer())) { long fp = s.getFilePointer(); String xml = s.readString(xmlLength).trim(); LOGGER.trace("xml = {}", xml); + if (!xml.startsWith(" 0) { parseXML(s, xml, fp); } @@ -1249,6 +1254,15 @@ private void parseImageProperties(Element root) throws FormatException { parseChannel(channel, appendChannels); } } + + // calls to parseChannel may have reset the channels list + // so there may be null elements that need to be removed + for (int i=0; i channels.size()) { + channels.add(null); + } + if (index == channels.size()) { + channels.add(c); + } + else { + channels.set(index, c); + } } } }