Mantis 7833: Fix a condition where email sent from an object that is in

the process of being removed can cause a null reference
LSLKeyTest
Melanie Thielker 2016-03-03 17:08:56 +01:00
parent ab12a14279
commit c541b5cf43
1 changed files with 8 additions and 11 deletions

View File

@ -224,8 +224,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
return null; return null;
} }
private void resolveNamePositionRegionName(UUID objectID, out string ObjectName, out string ObjectAbsolutePosition, out string ObjectRegionName) private bool resolveNamePositionRegionName(UUID objectID, out string ObjectName, out string ObjectAbsolutePosition, out string ObjectRegionName)
{ {
ObjectName = ObjectAbsolutePosition = ObjectRegionName = String.Empty;
string m_ObjectRegionName; string m_ObjectRegionName;
int objectLocX; int objectLocX;
int objectLocY; int objectLocY;
@ -239,15 +240,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
ObjectAbsolutePosition = "(" + objectLocX + ", " + objectLocY + ", " + objectLocZ + ")"; ObjectAbsolutePosition = "(" + objectLocX + ", " + objectLocY + ", " + objectLocZ + ")";
ObjectName = part.Name; ObjectName = part.Name;
ObjectRegionName = m_ObjectRegionName; ObjectRegionName = m_ObjectRegionName;
return; return true;
} }
objectLocX = (int)part.AbsolutePosition.X; return false;
objectLocY = (int)part.AbsolutePosition.Y;
objectLocZ = (int)part.AbsolutePosition.Z;
ObjectAbsolutePosition = "(" + objectLocX + ", " + objectLocY + ", " + objectLocZ + ")";
ObjectName = part.Name;
ObjectRegionName = m_ObjectRegionName;
return;
} }
/// <summary> /// <summary>
@ -286,7 +281,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
string LastObjectPosition = string.Empty; string LastObjectPosition = string.Empty;
string LastObjectRegionName = string.Empty; string LastObjectRegionName = string.Empty;
resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName); if (!resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName))
return;
if (!address.EndsWith(m_InterObjectHostname)) if (!address.EndsWith(m_InterObjectHostname))
{ {
@ -302,7 +298,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
//Subject //Subject
emailMessage.Subject = subject; emailMessage.Subject = subject;
//TEXT Body //TEXT Body
resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName); if (!resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName))
return;
emailMessage.BodyText = "Object-Name: " + LastObjectName + emailMessage.BodyText = "Object-Name: " + LastObjectName +
"\nRegion: " + LastObjectRegionName + "\nLocal-Position: " + "\nRegion: " + LastObjectRegionName + "\nLocal-Position: " +
LastObjectPosition + "\n\n" + body; LastObjectPosition + "\n\n" + body;