From bb48fae5ceb577118cad436e7b0abe72f33ba031 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Thu, 9 Nov 2017 18:29:34 +0000
Subject: [PATCH] SL-786 - control avatar deletion

---
 indra/newview/llviewerobject.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index e49c37be5ef..3435217fa48 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2969,9 +2969,11 @@ void LLViewerObject::unlinkControlAvatar()
     if (isRootEdit())
     {
         // This will remove the entire linkset from the control avatar
-        LLControlAvatar *av = mControlAvatar;
-        mControlAvatar = NULL;
-        av->markForDeath();
+        if (mControlAvatar)
+        {
+            mControlAvatar->markForDeath();
+            mControlAvatar = NULL;
+        }
     }
     // For non-root prims, removing from the linkset will
     // automatically remove the control avatar connection.
-- 
GitLab