diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index bd632c10dd5359ddd65ad29510f4c83a218012ef..b15ea7d79fa834378b9b20cb18fba0cd1ac0c91d 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1399,7 +1399,8 @@ bool LLAppViewer::doFrame()
 			// Scan keyboard for movement keys.  Command keys and typing
 			// are handled by windows callbacks.  Don't do this until we're
 			// done initializing.  JC
-			if ((gHeadlessClient || gViewerWindow->getWindow()->getVisible())
+			if (gViewerWindow
+				&& (gHeadlessClient || gViewerWindow->getWindow()->getVisible())
 				&& gViewerWindow->getActive()
 				&& !gViewerWindow->getWindow()->getMinimized()
 				&& LLStartUp::getStartupState() == STATE_STARTED