From 2c23acf39e810fd43f9ce5af0a4c3e4d952f2081 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Fri, 16 Nov 2012 01:18:08 +0100 Subject: SI-6634 Fixes data corruption issue in ListBuffer#remove This is the cut-down version with minimally invasive changes, e. g. keeping the "auto-correcting" bounds algorithm. --- src/library/scala/collection/mutable/ListBuffer.scala | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 53b2b57f50..4715b6818a 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -249,7 +249,12 @@ final class ListBuffer[A] * @param n the index which refers to the first element to remove. * @param count the number of elements to remove. */ + @annotation.migration("Invalid input values will be rejected in future releases.", "2.11") override def remove(n: Int, count: Int) { + if (n >= len) + return + if (count < 0) + throw new IllegalArgumentException(s"removing negative number ($count) of elements") if (exported) copy() val n1 = n max 0 val count1 = count min (len - n1) -- cgit v1.2.3