mirror of
https://github.com/apple/swift-crypto
synced 2026-11-28 05:04:21 +00:00
fix possible overindexing (#90)
This commit is contained in:
1 parent
684952cafa
commit
d89b2ef9ed
1 file changed
+4
-6
@@ -42,12 +42,10 @@ extension DataProtocol {
|
||||
let ptr = UnsafeMutablePointer<UInt8>.allocate(capacity: hexLen)
|
||||
var offset = 0
|
||||
|
||||
self.regions.forEach { (_) in
|
||||
for i in self {
|
||||
ptr[Int(offset * 2)] = itoh((i >> 4) & 0xF)
|
||||
ptr[Int(offset * 2 + 1)] = itoh(i & 0xF)
|
||||
offset += 1
|
||||
}
|
||||
for i in self {
|
||||
ptr[Int(offset * 2)] = itoh((i >> 4) & 0xF)
|
||||
ptr[Int(offset * 2 + 1)] = itoh(i & 0xF)
|
||||
offset += 1
|
||||
}
|
||||
|
||||
return String(bytesNoCopy: ptr, length: hexLen, encoding: .utf8, freeWhenDone: true)!
|
||||
|
||||
Reference in new issue
Block a user