mi: Fix undefined memcpy in mieqGrowQueue

The first time we get here, eventQueue->events is NULL.
This commit is contained in:
Adam Jackson 2019-10-15 13:16:17 -04:00
parent 6fe7c43fa5
commit 9155e0c7c6
1 changed files with 7 additions and 5 deletions

View File

@ -126,11 +126,13 @@ mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents)
/* First copy the existing events */
first_hunk = eventQueue->nevents - eventQueue->head;
memcpy(new_events,
&eventQueue->events[eventQueue->head],
first_hunk * sizeof(EventRec));
memcpy(&new_events[first_hunk],
eventQueue->events, eventQueue->head * sizeof(EventRec));
if (eventQueue->events) {
memcpy(new_events,
&eventQueue->events[eventQueue->head],
first_hunk * sizeof(EventRec));
memcpy(&new_events[first_hunk],
eventQueue->events, eventQueue->head * sizeof(EventRec));
}
/* Initialize the new portion */
for (i = eventQueue->nevents; i < new_nevents; i++) {