diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp
index e11df06d868c6a87b82c28756348bf5ee24949b3..0341f2c693d010673230d95f42b2154faece02e1 100644
--- a/indra/newview/llnavigationbar.cpp
+++ b/indra/newview/llnavigationbar.cpp
@@ -375,7 +375,6 @@ void LLNavigationBar::draw()
 	if(mPurgeTPHistoryItems)
 	{
 		LLTeleportHistory::getInstance()->purgeItems();
-		onTeleportHistoryChanged();
 		mPurgeTPHistoryItems = false;
 	}
 
diff --git a/indra/newview/llteleporthistory.cpp b/indra/newview/llteleporthistory.cpp
index dcc85392f7e049b352bb15f60ecfe7dc0f422410..15684337f4aab8c4977e9a837c2cd06820505d5f 100644
--- a/indra/newview/llteleporthistory.cpp
+++ b/indra/newview/llteleporthistory.cpp
@@ -136,6 +136,7 @@ void LLTeleportHistory::updateCurrentLocation(const LLVector3d& new_pos)
 		if (mCurrentItem < 0 || mCurrentItem >= (int) mItems.size()) // sanity check
 		{
 			llwarns << "Invalid current item. (this should not happen)" << llendl;
+			llassert(!"Invalid current teleport histiry item");
 			return;
 		}
 		LLVector3 new_pos_local = gAgent.getPosAgentFromGlobal(new_pos);
@@ -166,6 +167,17 @@ void LLTeleportHistory::onHistoryChanged()
 
 void LLTeleportHistory::purgeItems()
 {
+	if (mItems.size() == 0) // no entries yet (we're called before login)
+	{
+		// If we don't return here the history will get into inconsistent state, hence:
+		// 1) updateCurrentLocation() will malfunction,
+		//    so further teleports will not properly update the history;
+		// 2) mHistoryChangedSignal subscribers will be notified
+		//    of such an invalid change. (EXT-6798)
+		// Both should not happen.
+		return;
+	}
+
 	if (mItems.size() > 0)
 	{
 		mItems.erase(mItems.begin(), mItems.end()-1);
diff --git a/indra/newview/llteleporthistorystorage.cpp b/indra/newview/llteleporthistorystorage.cpp
index c635f914239d6a8d64a88a4c52540a2945d625df..430d62e15e19bf0ad17ecf664a3f634c13e29ca5 100644
--- a/indra/newview/llteleporthistorystorage.cpp
+++ b/indra/newview/llteleporthistorystorage.cpp
@@ -89,6 +89,13 @@ void LLTeleportHistoryStorage::onTeleportHistoryChange()
 	if (!th)
 		return;
 
+	// Hacky sanity check. (EXT-6798)
+	if (th->getItems().size() == 0)
+	{
+		llassert(!"Inconsistent teleport history state");
+		return;
+	}
+
 	const LLTeleportHistoryItem &item = th->getItems()[th->getCurrentItemIndex()];
 
 	addItem(item.mTitle, item.mGlobalPos);