diff --git a/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java b/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java index 5fa8024f98b..9fbdebad463 100644 --- a/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java +++ b/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java @@ -2187,9 +2187,12 @@ private void translateExperiment(Element root) throws FormatException { String y = getFirstNode(region, "Y").getTextContent(); String z = getFirstNode(region, "Z").getTextContent(); - positionsX[i] = x == null ? null : new Double(x); - positionsY[i] = y == null ? null : new Double(y); - positionsZ[i] = z == null ? null : new Double(z); + // safe to assume all 3 arrays have the same length + if (i < positionsX.length) { + positionsX[i] = x == null ? null : new Double(x); + positionsY[i] = y == null ? null : new Double(y); + positionsZ[i] = z == null ? null : new Double(z); + } } } }