task_queue_put - prevent dereference of null pointer

This commit is contained in:
twinaphex 2020-06-29 19:57:52 +02:00
parent bc61ceb338
commit 28399641da
1 changed files with 21 additions and 15 deletions

View File

@ -115,10 +115,15 @@ static void task_queue_put(task_queue_t *queue, retro_task_t *task)
if (queue->front)
{
/* Make sure to insert in order - the queue is sorted by 'when' so items that aren't scheduled
* to run immediately are at the back of the queue. Items with the same 'when' are inserted after
* all the other items with the same 'when'. This primarily affects items with a 'when' of 0.
/* Make sure to insert in order - the queue is
* sorted by 'when' so items that aren't scheduled
* to run immediately are at the back of the queue.
* Items with the same 'when' are inserted after
* all the other items with the same 'when'.
* This primarily affects items with a 'when' of 0.
*/
if (queue->back)
{
if (queue->back->when > task->when)
{
retro_task_t** prev = &queue->front;
@ -132,6 +137,7 @@ static void task_queue_put(task_queue_t *queue, retro_task_t *task)
queue->back->next = task;
}
}
else
queue->front = task;