Commit d2ed7e16 authored by Simon Morlat's avatar Simon Morlat

fix crash in event queue, while wrapping around. It was attempting to read an...

fix crash in event queue, while wrapping around. It was attempting to read an event while rptr==endptr.
parent c5b6a6df
......@@ -100,6 +100,12 @@ static bool_t read_event(MSEventQueue *q){
void *data;
int argsize;
int evsize;
ms_mutex_lock(&q->mutex);/*q->endptr can be changed by write_event() so mutex is needed*/
if (q->rptr>=q->endptr){
q->rptr=q->buffer;
}
ms_mutex_unlock(&q->mutex);
evsize=parse_event(q->rptr,&f,&id,&data,&argsize);
if (f) {
......@@ -108,9 +114,7 @@ static bool_t read_event(MSEventQueue *q){
q->current_notifier=NULL;
}
q->rptr+=evsize;
if (q->rptr>=q->endptr){
q->rptr=q->buffer;
}
ms_mutex_lock(&q->mutex);
q->freeroom+=evsize;
ms_mutex_unlock(&q->mutex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment