diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 554e93f403a..60a546a8104 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1203,9 +1203,11 @@ private SceneObjectPart BuildPrim(IDataReader row) int pseudocrc = (int)row["pseudocrc"]; if(pseudocrc != 0) prim.PseudoCRC = pseudocrc; - - if (prim.IsRoot && (row["linksetdata"] is DBNull) == false) + + if (!(row["linksetdata"] is DBNull)) + { prim.DeserializeLinksetData((byte[])row["linksetdata"]); + } return prim; } diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 6f0eddf1083..bbb7a407800 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs @@ -1812,7 +1812,7 @@ private SceneObjectPart buildPrim(DataRow row) prim.Animations = null; } - if ((row["linksetdata"] is DBNull) == false) + if (!(row["linksetdata"] is DBNull)) { prim.DeserializeLinksetData((byte[])row["LinksetData"]); } diff --git a/OpenSim/Region/Framework/Scenes/ProtectedData.cs b/OpenSim/Region/Framework/Scenes/ProtectedData.cs index 4f6e302a551..455adec302f 100644 --- a/OpenSim/Region/Framework/Scenes/ProtectedData.cs +++ b/OpenSim/Region/Framework/Scenes/ProtectedData.cs @@ -53,10 +53,12 @@ public Byte[] serialize() { using (MemoryStream ms = new MemoryStream()) { - BinaryWriter bw = new BinaryWriter(ms); - bw.Write(value); - bw.Write(pass); - return ms.ToArray(); + using (BinaryWriter bw = new BinaryWriter(ms)) + { + bw.Write(value); + bw.Write(pass); + return ms.ToArray(); + } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 781cd3845d6..f04c5ce2081 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5841,19 +5841,20 @@ public Byte[] SerializeLinksetData() { using (var ms = new MemoryStream()) { - - BinaryWriter bw = new BinaryWriter(ms); - bw.Write(LinksetData.Count); - foreach (KeyValuePair kvp in LinksetData) + using (BinaryWriter bw = new BinaryWriter(ms)) { - bw.Write(kvp.Key); - Byte[] prot = kvp.Value.serialize(); - - bw.Write(prot.Length); - bw.Write(prot); - } + bw.Write(LinksetData.Count); + foreach (KeyValuePair kvp in LinksetData) + { + bw.Write(kvp.Key); + Byte[] prot = kvp.Value.serialize(); - return ms.ToArray(); + bw.Write(prot.Length); + bw.Write(prot); + } + + return ms.ToArray(); + } } } } @@ -5864,16 +5865,18 @@ public void DeserializeLinksetData(Byte[] data) using (MemoryStream ms = new MemoryStream(data)) { - BinaryReader br = new BinaryReader(ms); - LinksetData = new Dictionary(); - - int count = br.ReadInt32(); - while (count>0) + using (BinaryReader br = new BinaryReader(ms)) { - LinksetData.Add(br.ReadString(), ProtectedData.deserialize(br.ReadBytes(br.ReadInt32()))); - count--; + LinksetData = new Dictionary(); + + int count = br.ReadInt32(); + while (count > 0) + { + LinksetData.Add(br.ReadString(), ProtectedData.deserialize(br.ReadBytes(br.ReadInt32()))); + count--; + } + updateLinksetDataAccounting(); } - updateLinksetDataAccounting(); } } @@ -5897,7 +5900,8 @@ public int AddOrUpdateLinksetDataKey(string key, string value, string pass) { pd=new ProtectedData(value, pass); LinksetData[key] = pd; - }else return -1; + } + else return -1; } else { @@ -5905,8 +5909,8 @@ public int AddOrUpdateLinksetDataKey(string key, string value, string pass) LinksetData[key] = pd; } - updateLinksetDataAccounting(); + if (LinksetDataOverLimit) { // Abort.