From 366bfe17ae46ddfe7b942b5851a1625072b4852b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 4 Oct 2009 07:41:10 -0700 Subject: [PATCH] Trying to avoid the null pointer exception in J2KImage, RunUpdate. --- OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 0e3630c128..713d43ac55 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs @@ -158,9 +158,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_currentPacket = m_stopPacket; return; } - + if (DiscardLevel >= 0 || m_stopPacket == 0) { + // This shouldn't happen, but if it does, we really can't proceed + if (Layers == null) + { + m_log.Warn("[J2KIMAGE]: RunUpdate() called with missing Layers. Canceling texture transfer"); + m_currentPacket = m_stopPacket; + return; + } + int maxDiscardLevel = Math.Max(0, Layers.Length - 1); // Treat initial texture downloads with a DiscardLevel of -1 a request for the highest DiscardLevel