diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 062a842748..e73cf9eca0 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -362,8 +362,6 @@ namespace OpenSim.Capabilities.Handlers { // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data - imgstream = new MemoryStream(); - // Decode image to System.Drawing.Image if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null) { @@ -404,10 +402,7 @@ namespace OpenSim.Capabilities.Handlers if(managedImage != null) managedImage.Clear(); if (imgstream != null) - { - imgstream.Close(); imgstream.Dispose(); - } } return data; diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs index d5df7a29bd..c339ec5d7e 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs @@ -368,9 +368,6 @@ namespace OpenSim.Capabilities.Handlers try { // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data - - imgstream = new MemoryStream(); - // Decode image to System.Drawing.Image if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null) { @@ -412,10 +409,7 @@ namespace OpenSim.Capabilities.Handlers managedImage.Clear(); if (imgstream != null) - { - imgstream.Close(); imgstream.Dispose(); - } } return data; diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs index 27e84b0f13..cfa9581d82 100644 --- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs @@ -216,6 +216,8 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures rc.Request(reqStream, m_Auth); m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", numberWears, agentId); } + if(reqStream != null) + reqStream.Dispose(); }, null, "XBakesModule.Store" ); } diff --git a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs index f292b9585d..ffd8ef6fb5 100644 --- a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs @@ -215,13 +215,16 @@ namespace OpenSim.Server.Handlers.MapImage private byte[] DocToBytes(XmlDocument doc) { - MemoryStream ms = new MemoryStream(); - XmlTextWriter xw = new XmlTextWriter(ms, null); - xw.Formatting = Formatting.Indented; - doc.WriteTo(xw); - xw.Flush(); - + using(MemoryStream ms = new MemoryStream()) + { + using(XmlTextWriter xw = new XmlTextWriter(ms,null)) + { + xw.Formatting = Formatting.Indented; + doc.WriteTo(xw); + xw.Flush(); + } return ms.ToArray(); + } } private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)