diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2012-11-16 01:18:08 +0100 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2012-11-16 23:11:55 +0100 |
commit | 2c23acf39e810fd43f9ce5af0a4c3e4d952f2081 (patch) | |
tree | e383e24325253e2985706c62e77c6f5f23f2977a /src | |
parent | c264898205efc10961a972bdd689c7e65dc25578 (diff) | |
download | scala-2c23acf39e810fd43f9ce5af0a4c3e4d952f2081.tar.gz scala-2c23acf39e810fd43f9ce5af0a4c3e4d952f2081.tar.bz2 scala-2c23acf39e810fd43f9ce5af0a4c3e4d952f2081.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/mutable/ListBuffer.scala | 5 |
1 files changed, 5 insertions, 0 deletions
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) |