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

View File

@ -190,7 +190,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// copy scripts or not. // copy scripts or not.
byte[] scbytes = System.Text.Encoding.UTF8.GetBytes(m_SourceCode); byte[] scbytes = System.Text.Encoding.UTF8.GetBytes(m_SourceCode);
StringBuilder sb = new StringBuilder((256 + 5) / 6); 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(); m_ScriptObjCodeKey = sb.ToString();
// But source code can be just a sixbit string itself // But source code can be just a sixbit string itself