Fixed a bug introduced in rev 1023 (ThuGie's crash)
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1029 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
8e84cbc083
commit
8f637d401d
@ -355,12 +355,15 @@ bool cByteBuffer::ReadBuf(void * a_Buffer, int a_Count)
|
||||
char * Dst = (char *)a_Buffer; // So that we can do byte math
|
||||
int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
|
||||
ASSERT(BytesToEndOfBuffer >= 0); // Sanity check
|
||||
if ((BytesToEndOfBuffer > 0) && (BytesToEndOfBuffer < a_Count))
|
||||
if (BytesToEndOfBuffer < a_Count)
|
||||
{
|
||||
// Reading across the ringbuffer end, read the first part and adjust parameters:
|
||||
memcpy(Dst, m_Buffer + m_ReadPos, BytesToEndOfBuffer);
|
||||
Dst += BytesToEndOfBuffer;
|
||||
a_Count -= BytesToEndOfBuffer;
|
||||
if (BytesToEndOfBuffer > 0)
|
||||
{
|
||||
memcpy(Dst, m_Buffer + m_ReadPos, BytesToEndOfBuffer);
|
||||
Dst += BytesToEndOfBuffer;
|
||||
a_Count -= BytesToEndOfBuffer;
|
||||
}
|
||||
m_ReadPos = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user