summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Janousek <tomi@nomi.cz>2015-09-19 01:09:24 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2015-09-21 11:53:49 +0200
commit8cca2bcae8d1393cb7de8f777ace6a918acabb28 (patch)
tree53400d136c1b7aa21a13f302e6648439a24b8023 /src
parent0f72dd37f85bbcaa07cfb325685dc019e6bc1c26 (diff)
downloadscala-8cca2bcae8d1393cb7de8f777ace6a918acabb28.tar.gz
scala-8cca2bcae8d1393cb7de8f777ace6a918acabb28.tar.bz2
scala-8cca2bcae8d1393cb7de8f777ace6a918acabb28.zip
Fix NPE in PagedSeq.slice at end of seq
See https://github.com/scala/scala-parser-combinators/issues/70 Basically the same thing as SI-6615, including the fact everything works okay if the PagedSeq is printed before calling slice. It might seem strange that this allows taking slices that start beyond the end, but - this was possible anyway if one forced the entire sequence, and - it is reasonable to be able to take a slice at the very end (not beyond it) and get an empty sequence, which is exactly what StreamReader in scala-parser-combinators does and gets an NPE.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/immutable/PagedSeq.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala
index f11217d26a..a86d4b6746 100644
--- a/src/library/scala/collection/immutable/PagedSeq.scala
+++ b/src/library/scala/collection/immutable/PagedSeq.scala
@@ -190,8 +190,8 @@ extends scala.collection.AbstractSeq[T]
val e = if (_end == UndeterminedEnd) _end else start + _end
var f = first1
while (f.end <= s && !f.isLast) {
- if (f.next eq null) f.addMore(more)
- f = f.next
+ if (f.next eq null) f = f.addMore(more)
+ else f = f.next
}
// Warning -- not refining `more` means that slices can freely request and obtain
// data outside of their slice. This is part of the design of PagedSeq