[client] overlay/msg: fix race condition in render
If an overlay is closed with overlayMsg_close, the message can be freed while it is still being used by msg_render, resulting in a segfault. Lock the message list for the duration of msg_render to fix this.
This commit is contained in:
1 parent
7e9e38faa5
commit
03ca20d3e4
3 files changed
+39
-25
No files matched your search
+23
-18
@@ -83,15 +83,18 @@ void ll_push(struct ll * list, void * data)
|
||||
bool ll_shift(struct ll * list, void ** data)
|
||||
{
|
||||
LG_LOCK(list->lock);
|
||||
bool result = ll_shift_nl(list, data);
|
||||
LG_UNLOCK(list->lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ll_shift_nl(struct ll * list, void ** data)
|
||||
{
|
||||
if (!list->head)
|
||||
{
|
||||
LG_UNLOCK(list->lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct ll_item * item = list->head;
|
||||
ll_removeNL(list, item);
|
||||
LG_UNLOCK(list->lock);
|
||||
|
||||
if (data)
|
||||
*data = item->data;
|
||||
@@ -103,29 +106,31 @@ bool ll_shift(struct ll * list, void ** data)
|
||||
bool ll_peek_head(struct ll * list, void ** data)
|
||||
{
|
||||
LG_LOCK(list->lock);
|
||||
if (!list->head)
|
||||
{
|
||||
LG_UNLOCK(list->lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
*data = list->head->data;
|
||||
bool result = ll_peek_head_nl(list, data);
|
||||
LG_UNLOCK(list->lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ll_peek_head_nl(struct ll * list, void ** data)
|
||||
{
|
||||
if (!list->head)
|
||||
return false;
|
||||
*data = list->head->data;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ll_peek_tail(struct ll * list, void ** data)
|
||||
{
|
||||
LG_LOCK(list->lock);
|
||||
if (!list->tail)
|
||||
{
|
||||
LG_UNLOCK(list->lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
*data = list->tail->data;
|
||||
bool result = ll_peek_tail_nl(list, data);
|
||||
LG_UNLOCK(list->lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ll_peek_tail_nl(struct ll * list, void ** data)
|
||||
{
|
||||
if (!list->tail)
|
||||
return false;
|
||||
*data = list->tail->data;
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user