Skip to content

Commit

Permalink
Merge pull request apple#175 from glessard/32-are-too-few-bits
Browse files Browse the repository at this point in the history
fix a 32-bit overflow issue
  • Loading branch information
glessard authored May 14, 2024
2 parents 36987d6 + 25c4b1a commit b642f54
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/System/MachPort.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
)
Expand Down

0 comments on commit b642f54

Please sign in to comment.