aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs53
1 files changed, 43 insertions, 10 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
index 583062d..b177103 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
@@ -229,22 +229,41 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
229 OpenMetaverse.AssetTexture texture = new OpenMetaverse.AssetTexture(m_asset.FullID, m_asset.Data); 229 OpenMetaverse.AssetTexture texture = new OpenMetaverse.AssetTexture(m_asset.FullID, m_asset.Data);
230 if (texture.DecodeLayerBoundaries()) 230 if (texture.DecodeLayerBoundaries())
231 { 231 {
232 download = new ImageDownload(texture, initialDiscardLevel, initialPriority, initialPacketNum); 232 bool sane = true;
233 ImageLoaded = true;
234 m_sending = true;
235 m_cancel = false;
236 sendFirstPacket = true;
237 233
238 return; 234 // Sanity check all of the layers
235 for (int i = 0; i < texture.LayerInfo.Length; i++)
236 {
237 if (texture.LayerInfo[i].End > texture.AssetData.Length)
238 {
239 sane = false;
240 break;
241 }
242 }
243
244 if (sane)
245 {
246 download = new ImageDownload(texture, initialDiscardLevel, initialPriority, initialPacketNum);
247 ImageLoaded = true;
248 m_sending = true;
249 m_cancel = false;
250 sendFirstPacket = true;
251 return;
252 }
253 else
254 {
255 m_log.Error("JPEG2000 texture decoding succeeded, but sanity check failed for " +
256 m_asset.FullID.ToString());
257 }
239 } 258 }
240 else 259 else
241 { 260 {
242 m_log.Error("JPEG2000 texture decoding failed"); 261 m_log.Error("JPEG2000 texture decoding failed for " + m_asset.FullID.ToString());
243 } 262 }
244 } 263 }
245 catch (Exception ex) 264 catch (Exception ex)
246 { 265 {
247 m_log.Error("JPEG2000 texture decoding threw an exception", ex); 266 m_log.Error("JPEG2000 texture decoding threw an exception for " + m_asset.FullID.ToString(), ex);
248 } 267 }
249 268
250 ImageLoaded = false; 269 ImageLoaded = false;
@@ -271,7 +290,14 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
271 else 290 else
272 { 291 {
273 byte[] firstImageData = new byte[ImageDownload.FIRST_IMAGE_PACKET_SIZE]; 292 byte[] firstImageData = new byte[ImageDownload.FIRST_IMAGE_PACKET_SIZE];
274 Buffer.BlockCopy(m_asset.Data, 0, firstImageData, 0, ImageDownload.FIRST_IMAGE_PACKET_SIZE); 293 try { Buffer.BlockCopy(m_asset.Data, 0, firstImageData, 0, ImageDownload.FIRST_IMAGE_PACKET_SIZE); }
294 catch (Exception)
295 {
296 m_log.Error("Texture data copy failed on first packet for " + m_asset.FullID.ToString());
297 m_cancel = true;
298 m_sending = false;
299 return;
300 }
275 RequestUser.SendImageFirstPart((ushort)download.TexturePacketCount(), m_asset.FullID, (uint)m_asset.Data.Length, firstImageData, 2); 301 RequestUser.SendImageFirstPart((ushort)download.TexturePacketCount(), m_asset.FullID, (uint)m_asset.Data.Length, firstImageData, 2);
276 } 302 }
277 } 303 }
@@ -280,7 +306,14 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
280 download.LastPacketSize() : ImageDownload.IMAGE_PACKET_SIZE; 306 download.LastPacketSize() : ImageDownload.IMAGE_PACKET_SIZE;
281 307
282 byte[] imageData = new byte[imagePacketSize]; 308 byte[] imageData = new byte[imagePacketSize];
283 Buffer.BlockCopy(m_asset.Data, download.CurrentBytePosition(), imageData, 0, imagePacketSize); 309 try { Buffer.BlockCopy(m_asset.Data, download.CurrentBytePosition(), imageData, 0, imagePacketSize); }
310 catch (Exception)
311 {
312 m_log.Error("Texture data copy failed for " + m_asset.FullID.ToString());
313 m_cancel = true;
314 m_sending = false;
315 return;
316 }
284 317
285 RequestUser.SendImageNextPart((ushort)download.CurrentPacket, m_asset.FullID, imageData); 318 RequestUser.SendImageNextPart((ushort)download.CurrentPacket, m_asset.FullID, imageData);
286 ++download.CurrentPacket; 319 ++download.CurrentPacket;