summaryrefslogtreecommitdiffstats
path: root/source/ByteBuffer.cpp
diff options
context:
space:
mode:
authormadmaxoft <madmaxoft@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-11-07 11:42:21 +0100
committermadmaxoft <madmaxoft@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-11-07 11:42:21 +0100
commit99a6252d6a0d7cd146d5c70d30b67cdb9a277ad5 (patch)
tree4f3217547f3043ad0fde4fadb679373ec833e4ec /source/ByteBuffer.cpp
parentRefactored the world time. (diff)
downloadcuberite-99a6252d6a0d7cd146d5c70d30b67cdb9a277ad5.tar
cuberite-99a6252d6a0d7cd146d5c70d30b67cdb9a277ad5.tar.gz
cuberite-99a6252d6a0d7cd146d5c70d30b67cdb9a277ad5.tar.bz2
cuberite-99a6252d6a0d7cd146d5c70d30b67cdb9a277ad5.tar.lz
cuberite-99a6252d6a0d7cd146d5c70d30b67cdb9a277ad5.tar.xz
cuberite-99a6252d6a0d7cd146d5c70d30b67cdb9a277ad5.tar.zst
cuberite-99a6252d6a0d7cd146d5c70d30b67cdb9a277ad5.zip
Diffstat (limited to 'source/ByteBuffer.cpp')
-rw-r--r--source/ByteBuffer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/source/ByteBuffer.cpp b/source/ByteBuffer.cpp
index 912f562f0..c1ff4c6fd 100644
--- a/source/ByteBuffer.cpp
+++ b/source/ByteBuffer.cpp
@@ -354,7 +354,8 @@ bool cByteBuffer::ReadBuf(void * a_Buffer, int a_Count)
NEEDBYTES(a_Count);
char * Dst = (char *)a_Buffer; // So that we can do byte math
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:
memcpy(Dst, m_Buffer + m_ReadPos, BytesToEndOfBuffer);