Commit b2a099b3 authored by Tim Clem's avatar Tim Clem Committed by Alexandre Julliard

server: Avoid a mach port leak on Apple Silicon.

Check for Rosetta before extracting the port right, since we won't need it in that case anyway.
parent 1135543d
...@@ -273,14 +273,6 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign ...@@ -273,14 +273,6 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
/* all other regs are handled on the client side */ /* all other regs are handled on the client side */
assert( flags == SERVER_CTX_DEBUG_REGISTERS ); assert( flags == SERVER_CTX_DEBUG_REGISTERS );
if (thread->unix_pid == -1 || !process_port ||
mach_port_extract_right( process_port, thread->unix_tid,
MACH_MSG_TYPE_COPY_SEND, &port, &type ))
{
set_error( STATUS_ACCESS_DENIED );
return;
}
if (is_rosetta()) if (is_rosetta())
{ {
/* Setting debug registers of a translated process is not supported cross-process /* Setting debug registers of a translated process is not supported cross-process
...@@ -290,6 +282,14 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign ...@@ -290,6 +282,14 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
return; return;
} }
if (thread->unix_pid == -1 || !process_port ||
mach_port_extract_right( process_port, thread->unix_tid,
MACH_MSG_TYPE_COPY_SEND, &port, &type ))
{
set_error( STATUS_ACCESS_DENIED );
return;
}
/* get the debug state to determine which flavor to use */ /* get the debug state to determine which flavor to use */
ret = thread_get_state(port, x86_DEBUG_STATE, (thread_state_t)&state, &count); ret = thread_get_state(port, x86_DEBUG_STATE, (thread_state_t)&state, &count);
if (ret) if (ret)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment