Yengine: use using...

0.9.1.0-post-fixes
UbitUmarov 2018-11-20 23:07:14 +00:00
parent 3e5ca6efd6
commit fb0c8036f0
2 changed files with 14 additions and 10 deletions

View File

@ -87,10 +87,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
CheckRunLockInvariants(true);
// Get copy of script globals and stack in relocateable form.
MemoryStream snapshotStream = new MemoryStream();
MigrateOutEventHandler(snapshotStream);
Byte[] snapshotBytes = snapshotStream.ToArray();
snapshotStream.Close();
Byte[] snapshotBytes;
using (MemoryStream snapshotStream = new MemoryStream())
{
MigrateOutEventHandler(snapshotStream);
snapshotBytes = snapshotStream.ToArray();
}
string snapshotString = Convert.ToBase64String(snapshotBytes);
XmlElement snapshotN = doc.CreateElement("", "Snapshot", "");
snapshotN.AppendChild(doc.CreateTextNode(snapshotString));
@ -180,11 +183,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// scriptStateN represents the contents of the .state file so
// write the .state file while we are here.
FileStream fs = File.Create(m_StateFileName);
StreamWriter sw = new StreamWriter(fs);
sw.Write(scriptStateN.OuterXml);
sw.Close();
fs.Close();
using(FileStream fs = File.Create(m_StateFileName))
{
using(StreamWriter sw = new StreamWriter(fs))
sw.Write(scriptStateN.OuterXml);
}
return scriptStateN;
}

View File

@ -190,7 +190,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// copy scripts or not.
byte[] scbytes = System.Text.Encoding.UTF8.GetBytes(m_SourceCode);
StringBuilder sb = new StringBuilder((256 + 5) / 6);
ByteArrayToSixbitStr(sb, System.Security.Cryptography.SHA256.Create().ComputeHash(scbytes));
using (System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create())
ByteArrayToSixbitStr(sb, sha.ComputeHash(scbytes));
m_ScriptObjCodeKey = sb.ToString();
// But source code can be just a sixbit string itself