mirror of https://github.com/FreeRDP/FreeRDP
Fix some corner cases in ringbuffer and make unitary test have no leak
This commit is contained in:
parent
5234e05843
commit
a04843bc9e
|
@ -69,6 +69,7 @@ static BOOL ringbuffer_realloc(RingBuffer *rb, size_t targetSize)
|
|||
if (!newData)
|
||||
return FALSE;
|
||||
rb->readPtr = rb->writePtr = 0;
|
||||
rb->buffer = newData;
|
||||
}
|
||||
else if ((rb->writePtr >= rb->readPtr) && (rb->writePtr < targetSize))
|
||||
{
|
||||
|
@ -118,6 +119,7 @@ static BOOL ringbuffer_realloc(RingBuffer *rb, size_t targetSize)
|
|||
}
|
||||
rb->writePtr = rb->size - rb->freeSize;
|
||||
rb->readPtr = 0;
|
||||
free(rb->buffer);
|
||||
rb->buffer = newData;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ BOOL test_overlaps(void)
|
|||
if (ringbuffer_capacity(&rb) != 5)
|
||||
goto error;
|
||||
|
||||
ringbuffer_destroy(&rb);
|
||||
return TRUE;
|
||||
error:
|
||||
ringbuffer_destroy(&rb);
|
||||
|
@ -220,6 +221,9 @@ int TestRingBuffer(int argc, char* argv[])
|
|||
return -1;
|
||||
}
|
||||
fprintf(stderr, "ok\n");
|
||||
|
||||
ringbuffer_destroy(&ringBuffer);
|
||||
free(tmpBuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue