register.c: Avoid potential race condition (Coverity 1477510)

Wrap writing to cur_cb_name in a mutex, to avoid
potential race conditions.
Fixes Coverity 1477510.
This commit is contained in:
Moshe Kaplan 2022-06-29 11:21:25 -04:00
parent ac4b9e174d
commit 1b586a66df
1 changed files with 1 additions and 1 deletions

View File

@ -119,12 +119,12 @@ register_all_protocol_handoffs_worker(void *arg _U_)
void
register_all_protocol_handoffs(register_cb cb, gpointer cb_data)
{
cur_cb_name = NULL;
const char *cb_name;
gboolean called_back = FALSE;
GThread *raphw_thread;
const char *error_message;
set_cb_name(NULL);
raphw_thread = g_thread_new("register_all_protocol_handoffs_worker", &register_all_protocol_handoffs_worker, NULL);
while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) {
g_mutex_lock(&cur_cb_name_mtx);