diff --git a/indra/newview/llfloaterscriptdebug.cpp b/indra/newview/llfloaterscriptdebug.cpp
index 468537e6599cdd912f9532a3d59cc4a40e042dd3..1ea3a07536d1f4656ac82012a4dfaeb5e83d1cfb 100644
--- a/indra/newview/llfloaterscriptdebug.cpp
+++ b/indra/newview/llfloaterscriptdebug.cpp
@@ -138,7 +138,10 @@ void LLFloaterScriptDebug::addScriptLine(const std::string &utf8mesg, const std:
 	{
 		if(objectp->isHUDAttachment())
 		{
-			((LLViewerObject*)gAgentAvatarp)->setIcon(LLViewerTextureManager::getFetchedTextureFromFile("script_error.j2c", FTT_LOCAL_FILE, TRUE, LLGLTexture::BOOST_UI));
+			if (isAgentAvatarValid())
+			{
+				((LLViewerObject*)gAgentAvatarp)->setIcon(LLViewerTextureManager::getFetchedTextureFromFile("script_error.j2c", FTT_LOCAL_FILE, TRUE, LLGLTexture::BOOST_UI));
+			}
 		}
 		else
 		{