From 8aa907cceb3e5eda94319bd847a3a1cfeb9f6a0d Mon Sep 17 00:00:00 2001 From: seasonyuu Date: Thu, 12 Sep 2024 17:03:44 +0800 Subject: [PATCH] fix crash when hook_start without permission in darwin --- src/lib/uiohook_worker.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/uiohook_worker.c b/src/lib/uiohook_worker.c index cc80da1..cd5584f 100644 --- a/src/lib/uiohook_worker.c +++ b/src/lib/uiohook_worker.c @@ -108,7 +108,6 @@ void hook_thread_proc(void* arg) { // Make sure we signal that we have passed any exception throwing code for // the waiting hook_enable(). uv_cond_signal(&hook_control_cond); - uv_mutex_unlock(&hook_control_mutex); } int hook_enable() { @@ -140,8 +139,9 @@ int hook_enable() { status = UIOHOOK_SUCCESS; } - logger_proc(LOG_LEVEL_DEBUG, "%s [%u]: Thread Result: (%#X).\n", - __FUNCTION__, __LINE__, status); + if (status != UIOHOOK_SUCCESS) { + uv_mutex_unlock(&hook_running_mutex); + } } else { status = UIOHOOK_ERROR_THREAD_CREATE;