fix(ai): protect window validation with mutex

The existence check accesses shared state without synchronization,
which can cause race conditions when called from background threads.
Explicitly locking the mutex ensures safe access during validation.
This commit is contained in:
2026-05-09 13:20:48 +00:00
parent acae543057
commit 07d267b5bc

View File

@@ -90,7 +90,10 @@ _aiwin_validate(gpointer user_data)
return NULL;
}
if (!wins_ai_exists((ProfAiWin*)user_data)) {
pthread_mutex_lock(&lock);
gboolean win_exists = wins_ai_exists((ProfAiWin*)user_data);
pthread_mutex_unlock(&lock);
if (!win_exists) {
log_warning("[AI-THREAD] aiwin=%p no longer exists — window was closed", (void*)user_data);
return NULL;
}