mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 15:16:22 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user