From 20cafc969d1ebc4f2497645b9f1d11b9074bc217 Mon Sep 17 00:00:00 2001 From: Rex Kerr Date: Fri, 21 Nov 2014 15:22:04 -0800 Subject: SI-8951 SeqView and StreamView stack-overflow on negative index after flatMap Checks and throws IndexOutOfBounds now. No test, caught and checked by scala-collections-laws (line 405 presently). --- src/library/scala/collection/SeqViewLike.scala | 1 + 1 file changed, 1 insertion(+) (limited to 'src/library') diff --git a/src/library/scala/collection/SeqViewLike.scala b/src/library/scala/collection/SeqViewLike.scala index e719f19c78..ef6d2272cb 100644 --- a/src/library/scala/collection/SeqViewLike.scala +++ b/src/library/scala/collection/SeqViewLike.scala @@ -83,6 +83,7 @@ trait SeqViewLike[+A, } def length = index(self.length) def apply(idx: Int) = { + if (idx < 0 || idx >= self.length) throw new IndexOutOfBoundsException(idx.toString) val row = findRow(idx, 0, self.length - 1) mapping(self(row)).seq.toSeq(idx - index(row)) } -- cgit v1.2.3