From 99ac770abbe3a95887c4b10c82f3985aa878eeef Mon Sep 17 00:00:00 2001
From: Oren Hurvitz
Date: Sun, 1 Jun 2014 17:39:11 +0300
Subject: Close streams immediately when we finish using them
---
OpenSim/Capabilities/LLSD.cs | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
(limited to 'OpenSim/Capabilities/LLSD.cs')
diff --git a/OpenSim/Capabilities/LLSD.cs b/OpenSim/Capabilities/LLSD.cs
index eec9e61..c59cede 100644
--- a/OpenSim/Capabilities/LLSD.cs
+++ b/OpenSim/Capabilities/LLSD.cs
@@ -68,7 +68,10 @@ namespace OpenSim.Framework.Capabilities
///
public static object LLSDDeserialize(byte[] b)
{
- return LLSDDeserialize(new MemoryStream(b, false));
+ using (MemoryStream ms = new MemoryStream(b, false))
+ {
+ return LLSDDeserialize(ms);
+ }
}
///
@@ -78,21 +81,23 @@ namespace OpenSim.Framework.Capabilities
///
public static object LLSDDeserialize(Stream st)
{
- XmlTextReader reader = new XmlTextReader(st);
- reader.Read();
- SkipWS(reader);
+ using (XmlTextReader reader = new XmlTextReader(st))
+ {
+ reader.Read();
+ SkipWS(reader);
- if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "llsd")
- throw new LLSDParseException("Expected ");
+ if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "llsd")
+ throw new LLSDParseException("Expected ");
- reader.Read();
- object ret = LLSDParseOne(reader);
- SkipWS(reader);
+ reader.Read();
+ object ret = LLSDParseOne(reader);
+ SkipWS(reader);
- if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "llsd")
- throw new LLSDParseException("Expected ");
+ if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "llsd")
+ throw new LLSDParseException("Expected ");
- return ret;
+ return ret;
+ }
}
///
--
cgit v1.1