diff --git a/src/java/org/apache/poi/ddf/EscherPropertyFactory.java b/src/java/org/apache/poi/ddf/EscherPropertyFactory.java index 3dcce79b86..3e653f5b8d 100644 --- a/src/java/org/apache/poi/ddf/EscherPropertyFactory.java +++ b/src/java/org/apache/poi/ddf/EscherPropertyFactory.java @@ -82,7 +82,14 @@ public final class EscherPropertyFactory { pos += ((EscherArrayProperty)p).setArrayData(data, pos); } else { byte[] complexData = ((EscherComplexProperty)p).getComplexData(); - System.arraycopy(data, pos, complexData, 0, complexData.length); + + int leftover = data.length-pos; + if(leftover < complexData.length){ + throw new IllegalStateException("Could not read complex escher property, lenght was " + complexData.length + ", but had only " + + leftover + " bytes left"); + } + + System.arraycopy(data, pos, complexData, 0, complexData.length); pos += complexData.length; } }