Hotfix for ThuGie's crash, with a sanity check in debug mode.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1023 0a769ca7-a7f5-676a-18bf-c427514a06d6master
parent
4cebaa99f8
commit
99a6252d6a
|
@ -354,7 +354,8 @@ bool cByteBuffer::ReadBuf(void * a_Buffer, int a_Count)
|
||||||
NEEDBYTES(a_Count);
|
NEEDBYTES(a_Count);
|
||||||
char * Dst = (char *)a_Buffer; // So that we can do byte math
|
char * Dst = (char *)a_Buffer; // So that we can do byte math
|
||||||
int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
|
int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
|
||||||
if (BytesToEndOfBuffer < a_Count)
|
ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
|
||||||
|
if ((BytesToEndOfBuffer > 0) && (BytesToEndOfBuffer < a_Count))
|
||||||
{
|
{
|
||||||
// Reading across the ringbuffer end, read the first part and adjust parameters:
|
// Reading across the ringbuffer end, read the first part and adjust parameters:
|
||||||
memcpy(Dst, m_Buffer + m_ReadPos, BytesToEndOfBuffer);
|
memcpy(Dst, m_Buffer + m_ReadPos, BytesToEndOfBuffer);
|
||||||
|
|
Loading…
Reference in New Issue