I have this code in a network extension:
private func pathForToken(token: audit_token_t) -> String? {
var tokenCopy = token
let bufferSize = UInt32(4096)
let bytes = UnsafeMutablePointer<UInt8>.allocate(capacity: Int(bufferSize))
let length = proc_pidpath_audittoken(&tokenCopy, bytes, bufferSize)
if length != 0 {
return String(cString: bytes).lowercased()
}
return nil
}
bytes
appears to be leaked -- the call stack is pathForToken(token:)
to specialized static UnsafeMutablePointer.allocate(capacity:)
Do I need to do something to ensure bytes
is released, since it doesn't seem to be happening on its own?