summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol17x.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-09-25 18:58:12 +0200
committerTycho <work.tycho+git@gmail.com>2014-09-25 18:58:12 +0200
commitb2f5ab96786528354164414ef1d4e23318c42ded (patch)
treed1815114848167d55c83bfc6f89d2c7048984cdb /src/Protocol/Protocol17x.cpp
parentFixed style (diff)
parentRedstone: Fixed a crash with repeaters on a chunk border. (diff)
downloadcuberite-b2f5ab96786528354164414ef1d4e23318c42ded.tar
cuberite-b2f5ab96786528354164414ef1d4e23318c42ded.tar.gz
cuberite-b2f5ab96786528354164414ef1d4e23318c42ded.tar.bz2
cuberite-b2f5ab96786528354164414ef1d4e23318c42ded.tar.lz
cuberite-b2f5ab96786528354164414ef1d4e23318c42ded.tar.xz
cuberite-b2f5ab96786528354164414ef1d4e23318c42ded.tar.zst
cuberite-b2f5ab96786528354164414ef1d4e23318c42ded.zip
Diffstat (limited to 'src/Protocol/Protocol17x.cpp')
-rw-r--r--src/Protocol/Protocol17x.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 7efcad626..36a808afe 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1519,9 +1519,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
m_ReceivedData.CommitRead();
- // Write one NUL extra, so that we can detect over-reads
- bb.Write("\0", 1);
-
UInt32 PacketType;
if (!bb.ReadVarInt(PacketType))
{
@@ -1529,6 +1526,9 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
break;
}
+ // Write one NUL extra, so that we can detect over-reads
+ bb.Write("\0", 1);
+
// Log the packet info into the comm log file:
if (g_ShouldLogCommIn)
{
@@ -1536,7 +1536,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
bb.ReadAll(PacketData);
bb.ResetRead();
bb.ReadVarInt(PacketType);
- ASSERT(PacketData.size() > 0);
+ ASSERT(PacketData.size() > 0); // We have written an extra NUL, so there had to be at least one byte read
PacketData.resize(PacketData.size() - 1);
AString PacketDataHex;
CreateHexDump(PacketDataHex, PacketData.data(), PacketData.size(), 16);