From a5ef634b06a87f3738e14f5a375e19c0c5ac38f3 Mon Sep 17 00:00:00 2001
From: Vadim ProductEngine <vsavchuk@productengine.com>
Date: Fri, 30 Mar 2012 15:45:54 +0300
Subject: [PATCH] MAINT-813 FIXED Potential fix for a crash at
 LLViewerRegion::getPosGlobalFromRegion.

As far as I can tell, if login fails with the "Region has begun the logout process" message, gAgentAvatarp gets destroyed, which leads to the crash.
Adding a check that should prevent it (could not reproduce to make sure).
---
 indra/newview/llviewerobject.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 37fb77a10ac..e590f29a9a3 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -143,7 +143,10 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco
 			}
 			else 
 			{
-				gAgentAvatarp->updateRegion(regionp);
+				if (isAgentAvatarValid())
+				{
+					gAgentAvatarp->updateRegion(regionp);
+				}
 			}
 			res = gAgentAvatarp;
 		}
-- 
GitLab