From 78359c108dfbecc9d8b7a26712eed061c1c0d648 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 15 Jul 2019 22:10:47 +0100 Subject: mantis 8563: do not modify collection inside a loop on it a foreach on it --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5c04659..5d72858 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -14192,15 +14192,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition).LandData; - if (land.OwnerID == m_host.OwnerID) + if (land.OwnerID == m_host.OwnerID && land.ParcelAccessList.Count > 0) { + var todelete = new List(); foreach (LandAccessEntry entry in land.ParcelAccessList) { if (entry.Flags == AccessList.Ban) - { - land.ParcelAccessList.Remove(entry); - } + todelete.Add(entry); } + foreach (LandAccessEntry entry in todelete) + land.ParcelAccessList.Remove(entry); } ScriptSleep(m_sleepMsOnResetLandBanList); } @@ -14209,15 +14210,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition).LandData; - if (land.OwnerID == m_host.OwnerID) + if (land.OwnerID == m_host.OwnerID && land.ParcelAccessList.Count > 0) { + var todelete = new List(); foreach (LandAccessEntry entry in land.ParcelAccessList) { if (entry.Flags == AccessList.Access) - { - land.ParcelAccessList.Remove(entry); - } + todelete.Add(entry); } + foreach (LandAccessEntry entry in todelete) + land.ParcelAccessList.Remove(entry); } ScriptSleep(m_sleepMsOnResetLandPassList); } -- cgit v1.1