libwinpr-utils: fix 3 logic errors

This commit is contained in:
pony 2017-02-15 11:44:19 +08:00 committed by Armin Novak
parent 0540e189b1
commit a57adc3fde
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;