From cf7b51db3b289d2b1782ffb863912217936dcccb Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Mon, 17 Dec 2012 23:28:08 -0500 Subject: Fix Iterator#copyToArray (fixes SI-6827). As pointed out in #scala, when using a non-zero start it's possible to get an ArrayIndexOutOfBoundsException due to an incorrect bounds check. This patch fixes this, as well as another potential bounds error, and adds test cases. Incorporates some other suggestions by Som-Snytt to ensure that callers will get useful error messages in cases where the start parameter is wrong (negative or out-of-array-bounds). Review by @som-snytt. --- test/files/run/t6827.check | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/files/run/t6827.check (limited to 'test/files/run/t6827.check') diff --git a/test/files/run/t6827.check b/test/files/run/t6827.check new file mode 100644 index 0000000000..3a3a71c67d --- /dev/null +++ b/test/files/run/t6827.check @@ -0,0 +1,15 @@ +start at -5: java.lang.IllegalArgumentException: requirement failed: start -5 out of range 10 +start at -1: java.lang.IllegalArgumentException: requirement failed: start -1 out of range 10 +start at limit: java.lang.IllegalArgumentException: requirement failed: start 10 out of range 10 +start at limit-1: ok +first 10: ok +read all: ok +test huge len: ok +5 from 5: ok +20 from 5: ok +test len overflow: ok +start beyond limit: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 +read 0: ok +read -1: ok +invalid read 0: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 +invalid read -1: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 -- cgit v1.2.3