Merge pull request #3769 from akallabeth/queue_fix

libwinpr-utils: fix 3 logic errors
This commit is contained in:
Bernhard Miklautz 2017-02-15 15:50:49 +01:00 committed by GitHub
commit a1d87fee97
2 changed files with 6 additions and 4 deletions

View File

@ -86,9 +86,10 @@ BOOL MessageQueue_Dispatch(wMessageQueue* queue, wMessage* message)
goto out;
queue->array = new_arr;
queue->capacity = new_capacity;
ZeroMemory(&(queue->array[old_capacity]), old_capacity * sizeof(wMessage));
ZeroMemory(&(queue->array[old_capacity]), (new_capacity - old_capacity) * sizeof(wMessage));
if (queue->tail < old_capacity)
/* rearrange wrapped entries */
if (queue->tail <= queue->head)
{
CopyMemory(&(queue->array[old_capacity]), queue->array, queue->tail * sizeof(wMessage));
queue->tail += old_capacity;

View File

@ -164,9 +164,10 @@ BOOL Queue_Enqueue(wQueue* queue, void* obj)
queue->capacity = new_capacity;
queue->array = newArray;
ZeroMemory(&(queue->array[old_capacity]), old_capacity * sizeof(void*));
ZeroMemory(&(queue->array[old_capacity]), (new_capacity - old_capacity) * sizeof(void*));
if (queue->tail < old_capacity)
/* rearrange wrapped entries */
if (queue->tail <= queue->head)
{
CopyMemory(&(queue->array[old_capacity]), queue->array, queue->tail * sizeof(void*));
queue->tail += old_capacity;