We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c01181 commit a0bf388Copy full SHA for a0bf388
stdlib/public/core/StringUTF8Validation.swift
@@ -104,6 +104,11 @@ internal func validateUTF8(_ buf: UnsafeBufferPointer<UInt8>) -> UTF8ValidationR
104
_ = iter.next()
105
while let cu = iter.next(), UTF8.isContinuation(cu) {
106
endIndex += 1
107
+ // Unicode's Maximal subpart of an ill-formed subsequence will yield
108
+ // at most 3 bytes of error.
109
+ if buf.distance(from: buf.startIndex, to: endIndex) >= 3 {
110
+ break
111
+ }
112
}
113
let illegalRange = Range(buf.startIndex...endIndex)
114
_internalInvariant(illegalRange.clamped(to: (buf.startIndex..<buf.endIndex)) == illegalRange,
0 commit comments