fix possible overindexing (#90)

This commit is contained in:
Benedek Kozma authored and GitHub committed 2021-09-02 10:43:04 +01:00
1 parent 684952cafa
commit d89b2ef9ed
1 file changed
+4 -6
+4 -6
View File
@@ -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)!