Avoid NRE if client sends unrecognized packet type.

0.6.4-rc1
Jeff Ames 2009-03-03 17:39:57 +00:00
parent b5cc69f8b2
commit d81bc4b5f2
1 changed files with 8 additions and 1 deletions

View File

@ -27,13 +27,17 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse;
using OpenMetaverse.Packets;
using log4net;
namespace OpenSim.Framework
{
public sealed class PacketPool
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly PacketPool instance = new PacketPool();
private bool packetPoolEnabled = false;
@ -119,7 +123,10 @@ namespace OpenSim.Framework
int i = 0;
Packet packet = GetPacket(type);
packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer);
if (packet == null)
m_log.WarnFormat("[PACKETPOOL]: Failed to get packet of type {0}", type);
else
packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer);
return packet;
}