Commits

Monroe Linden committed 684de17

Fix for a crash on startup/shutdown introduced in the tip of viewer-2-0 very recently.

list.erase(list.find()) is not safe, because erasing list.end() is undefined. Check to make sure the find succeeded before doing the erase.

Reviewed by Richard at http://codereview.lindenlab.com/341001

Comments (0)

Files changed (1)

indra/newview/llpopupview.cpp

 {
 	if (popup)
 	{
-		mPopups.erase(std::find(mPopups.begin(), mPopups.end(), popup->getHandle()));
+		popup_list_t::iterator iter = std::find(mPopups.begin(), mPopups.end(), popup->getHandle());
+		if(iter != mPopups.end())
+		{
+			mPopups.erase(iter);
+		}
 		mPopups.push_front(popup->getHandle());
 	}
 }
 		{
 			gFocusMgr.setKeyboardFocus(NULL);
 		}
-		mPopups.erase(std::find(mPopups.begin(), mPopups.end(), popup->getHandle()));
+		popup_list_t::iterator iter = std::find(mPopups.begin(), mPopups.end(), popup->getHandle());
+		if(iter != mPopups.end())
+		{
+			mPopups.erase(iter);
+		}
 		popup->onTopLost();
 	}
 }