Merge pull request #175 from glessard/32-are-too-few-bits

fix a 32-bit overflow issue
This commit is contained in:
Guillaume Lessard authored and GitHub committed 2024-05-14 11:32:44 -07:00
commit b642f54526
1 file changed
+8 -4
+8 -4
View File
@@ -56,8 +56,10 @@ public enum Mach {
self._name = name
if RightType.self == ReceiveRight.self {
precondition(name != 0xFFFFFFFF /* MACH_PORT_DEAD */,
"Receive rights cannot be dead names")
precondition(
_name != (0xFFFFFFFF as mach_port_name_t) /* MACH_PORT_DEAD */,
"Receive rights cannot be dead names"
)
let secret = mach_port_context_t(arc4random())
_machPrecondition(mach_port_guard(mach_task_self_, name, secret, 0))
@@ -87,8 +89,10 @@ public enum Mach {
deinit {
if RightType.self == ReceiveRight.self {
precondition(_name != 0xFFFFFFFF /* MACH_PORT_DEAD */,
"Receive rights cannot be dead names")
precondition(
_name != (0xFFFFFFFF as mach_port_name_t) /* MACH_PORT_DEAD */,
"Receive rights cannot be dead names"
)
_machPrecondition(
mach_port_destruct(mach_task_self_, _name, 0, _context)
)