stdlib/String.UnicodeScalarView: fix out-of-bounds read of the

underlying NSString when it ends in a high-surrogate code unit

The tests did not catch this because they were creating CFString, which,
as it turns out, does not perform bounds checking.  Replaced the use of
CFString with a custom NSString subclass.

Swift SVN r19329
This commit is contained in:
Dmitri Hrybenko
2014-06-30 11:54:51 +00:00
parent 92d8688983
commit 450c21f4ec
2 changed files with 7 additions and 17 deletions

View File

@@ -31,6 +31,9 @@ extension String {
base = core
}
mutating func next() -> UTF16.CodeUnit? {
if idx == base.endIndex {
return .None
}
return self.base[idx++]
}
}