Module: wine Branch: master Commit: b2a099b3ceec6fef05c455408c05714232cb466f URL: https://gitlab.winehq.org/wine/wine/-/commit/b2a099b3ceec6fef05c455408c05714...
Author: Tim Clem tclem@codeweavers.com Date: Wed Aug 9 11:22:58 2023 -0700
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.
---
server/mach.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/server/mach.c b/server/mach.c index 3852bb3ee5b..a619c1cd2a8 100644 --- a/server/mach.c +++ b/server/mach.c @@ -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 */ 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()) { /* 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 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 */ ret = thread_get_state(port, x86_DEBUG_STATE, (thread_state_t)&state, &count); if (ret)