Merge pull request #10744 from OatmealDome/ventura-exception

MemTools: Always provide a valid pointer in send_msg for mach_msg_overwrite
This commit is contained in:
Mai 2022-06-12 03:44:18 -04:00 committed by GitHub
commit f1993182f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -157,7 +157,6 @@ static void ExceptionThread(mach_port_t port)
#pragma pack()
memset(&msg_in, 0xee, sizeof(msg_in));
memset(&msg_out, 0xee, sizeof(msg_out));
mach_msg_header_t* send_msg = nullptr;
mach_msg_size_t send_size = 0;
mach_msg_option_t option = MACH_RCV_MSG;
while (true)
@ -167,7 +166,7 @@ static void ExceptionThread(mach_port_t port)
// thread_set_exception_ports, or MACH_NOTIFY_NO_SENDERS due to
// mach_port_request_notification.
CheckKR("mach_msg_overwrite",
mach_msg_overwrite(send_msg, option, send_size, sizeof(msg_in), port,
mach_msg_overwrite(&msg_out.Head, option, send_size, sizeof(msg_in), port,
MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL, &msg_in.Head, 0));
if (msg_in.Head.msgh_id == MACH_NOTIFY_NO_SENDERS)
@ -216,7 +215,6 @@ static void ExceptionThread(mach_port_t port)
msg_out.Head.msgh_size =
offsetof(__typeof__(msg_out), new_state) + msg_out.new_stateCnt * sizeof(natural_t);
send_msg = &msg_out.Head;
send_size = msg_out.Head.msgh_size;
option |= MACH_SEND_MSG;
}