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