From 73c47f720583da40496d5c8fe94f35ed0aec640f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 9 Mar 2012 02:22:22 +0000 Subject: [PATCH] Remove a race condition from SP.Set_AbsolutePosition where we assume the ParentPart is still not null if the ParentID != 0 Another thread could come in and stand the avatar between those two instructions. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9d5cdfaf1b..be56fe136c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -455,12 +455,12 @@ namespace OpenSim.Region.Framework.Scenes // in the sim unless the avatar is on a sit target. While // on a sit target, m_pos will contain the desired offset // without the parent rotation applied. - if (ParentID != 0) - { - SceneObjectPart part = ParentPart; - return part.AbsolutePosition + (m_pos * part.GetWorldRotation()); - } + SceneObjectPart sitPart = ParentPart; + + if (sitPart != null) + return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); } + return m_pos; } set