From 669dcf2c25f7f1c63612e55dc478f8837a50409a Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Wed, 9 Aug 2023 13:48:55 -0700 Subject: [PATCH] ensure Mach.Port lives until the function returns --- Tests/SystemTests/MachPortTests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/SystemTests/MachPortTests.swift b/Tests/SystemTests/MachPortTests.swift index cf68cd6..299809c 100644 --- a/Tests/SystemTests/MachPortTests.swift +++ b/Tests/SystemTests/MachPortTests.swift @@ -29,7 +29,8 @@ final class MachPortTests: XCTestCase { } func scopedReceiveRight(name:mach_port_name_t) -> mach_port_urefs_t { - _ = Mach.Port(name:name) // this should automatically deallocate when going out of scope + let right = Mach.Port(name:name) // this should automatically deallocate when going out of scope + defer { _ = right } return refCountForMachPortName(name:name, kind:MACH_PORT_RIGHT_RECEIVE) }