diff --git a/classpath/java/io/FileOutputStream.java b/classpath/java/io/FileOutputStream.java index 8732004e7..f5518d797 100644 --- a/classpath/java/io/FileOutputStream.java +++ b/classpath/java/io/FileOutputStream.java @@ -52,7 +52,7 @@ public void write(byte[] b, int offset, int length) throws IOException { throw new NullPointerException(); } - if (offset < 0 || offset + length > b.length) { + if (offset < 0 || length < 0 || length > b.length || offset > b.length - length) { throw new ArrayIndexOutOfBoundsException(); }