Fix crash on empty player list updates

Player list updates on MC 1.8 handler did not take into account the
amount of items in the list and were only processing the first item,
including when there wasn't any item to process. Unfortunately some
weird servers were sending useless empty tab-list updates, causing a
crash. Should fix issue #78 and forum posts 1267, 1269, 1284. Thanks
dbear20, link3321, gerik43, Darkaegis, k3ldon and Ryan6578 for their bug
reports! :)
This commit is contained in:
ORelio 2015-06-03 12:00:25 +02:00
parent 80b468b301
commit 840ac01dc5

View file

@ -146,6 +146,8 @@ namespace MinecraftClient.Protocol.Handlers
case 0x38: //Player List update
int action = readNextVarInt(ref packetData);
int numActions = readNextVarInt(ref packetData);
for (int i = 0; i < numActions; i++)
{
Guid uuid = readNextUUID(ref packetData);
switch (action)
{
@ -160,6 +162,7 @@ namespace MinecraftClient.Protocol.Handlers
//Unknown player list item type
break;
}
}
break;
case 0x3A: //Tab-Complete Result
int autocomplete_count = readNextVarInt(ref packetData);
@ -281,16 +284,9 @@ namespace MinecraftClient.Protocol.Handlers
/// <returns>The uuid</returns>
private Guid readNextUUID(ref byte[] cache)
{
try
{
return new Guid(readData(16, ref cache));
}
catch (ArgumentException)
{
return Guid.Empty;
}
}
/// <summary>
/// Read a byte array from a cache of bytes and remove it from the cache