diff options
author | Melanie Thielker | 2009-04-29 21:01:01 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-04-29 21:01:01 +0000 |
commit | e2327384e0c01cdf9795b4085e07e668c372713b (patch) | |
tree | eb6db46aca34967d7c50ab227b709dacdabd3ada /OpenSim/Region | |
parent | Fix a crash that will hit when an image asset is truncated in storage (diff) | |
download | opensim-SC-e2327384e0c01cdf9795b4085e07e668c372713b.zip opensim-SC-e2327384e0c01cdf9795b4085e07e668c372713b.tar.gz opensim-SC-e2327384e0c01cdf9795b4085e07e668c372713b.tar.bz2 opensim-SC-e2327384e0c01cdf9795b4085e07e668c372713b.tar.xz |
Catch another j2k decode exception that can be caused by a bad asset
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index e72cdab..6878fe5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | |||
@@ -210,47 +210,52 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
210 | bool complete = false; | 210 | bool complete = false; |
211 | int imagePacketSize = ((int)m_packetNumber == (TexturePacketCount())) ? LastPacketSize() : cImagePacketSize; | 211 | int imagePacketSize = ((int)m_packetNumber == (TexturePacketCount())) ? LastPacketSize() : cImagePacketSize; |
212 | 212 | ||
213 | if ((CurrentBytePosition() + cImagePacketSize) > m_asset.Data.Length) | 213 | try |
214 | { | 214 | { |
215 | imagePacketSize = LastPacketSize(); | 215 | if ((CurrentBytePosition() + cImagePacketSize) > m_asset.Data.Length) |
216 | complete=true; | ||
217 | if ((CurrentBytePosition() + imagePacketSize) > m_asset.Data.Length) | ||
218 | { | 216 | { |
219 | imagePacketSize = m_asset.Data.Length - CurrentBytePosition(); | 217 | imagePacketSize = LastPacketSize(); |
220 | complete = true; | 218 | complete=true; |
219 | if ((CurrentBytePosition() + imagePacketSize) > m_asset.Data.Length) | ||
220 | { | ||
221 | imagePacketSize = m_asset.Data.Length - CurrentBytePosition(); | ||
222 | complete = true; | ||
223 | } | ||
221 | } | 224 | } |
222 | } | 225 | |
223 | 226 | //It's concievable that the client might request packet one | |
224 | //It's concievable that the client might request packet one | 227 | //from a one packet image, which is really packet 0, |
225 | //from a one packet image, which is really packet 0, | 228 | //which would leave us with a negative imagePacketSize.. |
226 | //which would leave us with a negative imagePacketSize.. | 229 | if (imagePacketSize > 0) |
227 | if (imagePacketSize > 0) | ||
228 | { | ||
229 | byte[] imageData = new byte[imagePacketSize]; | ||
230 | try | ||
231 | { | 230 | { |
232 | Buffer.BlockCopy(m_asset.Data, CurrentBytePosition(), imageData, 0, imagePacketSize); | 231 | byte[] imageData = new byte[imagePacketSize]; |
232 | try | ||
233 | { | ||
234 | Buffer.BlockCopy(m_asset.Data, CurrentBytePosition(), imageData, 0, imagePacketSize); | ||
235 | } | ||
236 | catch (Exception e) | ||
237 | { | ||
238 | m_log.Error("Error copying texture block. Out of memory? imagePacketSize was " + imagePacketSize.ToString() + " on packet " + m_packetNumber.ToString() + " out of " + m_stopPacket.ToString() + ". Exception: " + e.ToString()); | ||
239 | return false; | ||
240 | } | ||
241 | |||
242 | //Send the packet | ||
243 | client.SendImageNextPart((ushort)(m_packetNumber-1), m_requestedUUID, imageData); | ||
244 | |||
233 | } | 245 | } |
234 | catch (Exception e) | 246 | if (complete) |
235 | { | 247 | { |
236 | m_log.Error("Error copying texture block. Out of memory? imagePacketSize was " + imagePacketSize.ToString() + " on packet " + m_packetNumber.ToString() + " out of " + m_stopPacket.ToString() + ". Exception: " + e.ToString()); | ||
237 | return false; | 248 | return false; |
238 | } | 249 | } |
239 | 250 | else | |
240 | //Send the packet | 251 | { |
241 | client.SendImageNextPart((ushort)(m_packetNumber-1), m_requestedUUID, imageData); | 252 | return true; |
242 | 253 | } | |
243 | } | 254 | } |
244 | if (complete) | 255 | catch (Exception e) |
245 | { | 256 | { |
246 | return false; | 257 | return false; |
247 | } | 258 | } |
248 | else | ||
249 | { | ||
250 | return true; | ||
251 | } | ||
252 | |||
253 | |||
254 | } | 259 | } |
255 | public bool SendPackets(LLClientView client) | 260 | public bool SendPackets(LLClientView client) |
256 | { | 261 | { |