ensure Mach.Port lives until the function returns

This commit is contained in:
Guillaume Lessard committed 2023-08-09 15:58:56 -07:00
1 parent 9123120c08
commit 669dcf2c25
1 file changed
+2 -1
+2 -1
View File
@@ -29,7 +29,8 @@ final class MachPortTests: XCTestCase {
}
func scopedReceiveRight(name:mach_port_name_t) -> mach_port_urefs_t {
_ = Mach.Port<Mach.ReceiveRight>(name:name) // this should automatically deallocate when going out of scope
let right = Mach.Port<Mach.ReceiveRight>(name:name) // this should automatically deallocate when going out of scope
defer { _ = right }
return refCountForMachPortName(name:name, kind:MACH_PORT_RIGHT_RECEIVE)
}