File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -155,10 +155,14 @@ fileprivate struct TokenData {
155
155
if hasCustomText {
156
156
// Copy the full token text, including trivia.
157
157
let startOffset = Int ( data. range. offset)
158
- var charPtr = UnsafeMutableRawPointer ( curPtr ) . assumingMemoryBound ( to : UInt8 . self )
158
+ let length = Int ( data . range . length )
159
159
let utf8 = source. utf8
160
+ precondition ( startOffset <= utf8. count)
161
+ precondition ( startOffset + length <= utf8. count)
160
162
let begin = utf8. index ( utf8. startIndex, offsetBy: startOffset)
161
- let end = utf8. index ( begin, offsetBy: Int ( data. range. length) )
163
+ let end = utf8. index ( begin, offsetBy: length)
164
+
165
+ var charPtr = UnsafeMutableRawPointer ( curPtr) . assumingMemoryBound ( to: UInt8 . self)
162
166
for ch in utf8 [ begin..< end] {
163
167
charPtr. pointee = ch
164
168
charPtr = charPtr. successor ( )
You can’t perform that action at this time.
0 commit comments