diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-11-10 15:02:20 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-11-10 15:02:20 +0100 |
commit | 8f637d401d3788af368ef336db7decb6a144c7ae (patch) | |
tree | 329040f144d8a3d27461226e34e94645d34b3cbc /source | |
parent | Protocol 1.4.2: found out and fixed the reason behind the fake "login" packet: the locale_viewdistance packet had been extended (diff) | |
download | cuberite-8f637d401d3788af368ef336db7decb6a144c7ae.tar cuberite-8f637d401d3788af368ef336db7decb6a144c7ae.tar.gz cuberite-8f637d401d3788af368ef336db7decb6a144c7ae.tar.bz2 cuberite-8f637d401d3788af368ef336db7decb6a144c7ae.tar.lz cuberite-8f637d401d3788af368ef336db7decb6a144c7ae.tar.xz cuberite-8f637d401d3788af368ef336db7decb6a144c7ae.tar.zst cuberite-8f637d401d3788af368ef336db7decb6a144c7ae.zip |
Diffstat (limited to 'source')
-rw-r--r-- | source/ByteBuffer.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/ByteBuffer.cpp b/source/ByteBuffer.cpp index c1ff4c6fd..623b865f4 100644 --- a/source/ByteBuffer.cpp +++ b/source/ByteBuffer.cpp @@ -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;
}
|