From 051858c3d25e5df8cbea0b3b19afb3c9921ea0e7 Mon Sep 17 00:00:00 2001
From: Cinder <cinder@sdf.org>
Date: Mon, 28 Mar 2016 20:49:44 -0600
Subject: [PATCH] Various null checks and etc. CID-42572 CID-42573 CID-42588
 CID-42594 CID-42634 CID-42441 CID-42462 CID-42472

---
 indra/newview/llchiclet.cpp                   |  2 +-
 indra/newview/llfloaterimsessiontab.cpp       |  5 ++--
 indra/newview/llinventorypanel.cpp            | 26 ++++++++++---------
 indra/newview/llpanelcontents.cpp             |  2 +-
 indra/newview/llpanelgrouplandmoney.cpp       |  8 +++---
 indra/newview/llpanelmediasettingsgeneral.cpp |  2 +-
 indra/newview/llpanelprimmediacontrols.cpp    |  5 ++--
 indra/newview/lltoolbarview.cpp               |  6 ++---
 8 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index 3d43571112..dbe7f3779b 100755
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -641,7 +641,7 @@ void LLChicletPanel::removeChiclet(const LLUUID& im_session_id)
 	{
 		LLIMChiclet* chiclet = dynamic_cast<LLIMChiclet*>(*it);
 
-		if(chiclet->getSessionId() == im_session_id)
+		if(chiclet && chiclet->getSessionId() == im_session_id)
 		{
 			removeChiclet(it);
 			return;
diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp
index 77b0201de2..2d52e7409e 100755
--- a/indra/newview/llfloaterimsessiontab.cpp
+++ b/indra/newview/llfloaterimsessiontab.cpp
@@ -926,7 +926,8 @@ void LLFloaterIMSessionTab::onOpen(const LLSD& key)
 	{
 		LLFloaterIMContainer* host_floater = dynamic_cast<LLFloaterIMContainer*>(getHost());
 		// Show the messages pane when opening a floater hosted in the Conversations
-		host_floater->collapseMessagesPane(false);
+		if (host_floater)
+            host_floater->collapseMessagesPane(false);
 	}
 
 	mInputButtonPanel->setVisible(isTornOff());
@@ -1102,7 +1103,7 @@ void LLFloaterIMSessionTab::saveCollapsedState()
 // virtual
 void LLFloaterIMSessionTab::applyMUPose(std::string& text)
 {
-	static LLCachedControl<bool> useMUPose(gSavedSettings, "AlchemyChatMUPose", false);
+	static LLCachedControl<bool> useMUPose(gSavedSettings, "AlchemyChatMUPose", false);
 	if (!useMUPose)
 		return;
 
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 3c8181b76d..51a6a57a5c 100755
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -1252,18 +1252,20 @@ LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel(BOOL auto_open)
 	for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end(); ++iter)
 	{
 		LLFloaterSidePanelContainer* inventory_floater = dynamic_cast<LLFloaterSidePanelContainer*>(*iter);
-		inventory_panel = inventory_floater->findChild<LLSidepanelInventory>("main_panel");
-
-		if (inventory_floater && inventory_panel && inventory_floater->getVisible())
-		{
-			S32 z_order = gFloaterView->getZOrder(inventory_floater);
-			if (z_order < z_min)
-			{
-				res = inventory_panel->getActivePanel();
-				z_min = z_order;
-				active_inv_floaterp = inventory_floater;
-			}
-		}
+		if (inventory_floater)
+        {
+            inventory_panel = inventory_floater->findChild<LLSidepanelInventory>("main_panel");
+            if (inventory_panel && inventory_floater->getVisible())
+            {
+                S32 z_order = gFloaterView->getZOrder(inventory_floater);
+                if (z_order < z_min)
+                {
+                    res = inventory_panel->getActivePanel();
+                    z_min = z_order;
+                    active_inv_floaterp = inventory_floater;
+                }
+            }
+        }
 	}
 
 	if (res)
diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp
index 451f41cd3b..caa830c68c 100755
--- a/indra/newview/llpanelcontents.cpp
+++ b/indra/newview/llpanelcontents.cpp
@@ -111,7 +111,7 @@ void LLPanelContents::getState(LLViewerObject *objectp )
 	}
 
 	LLUUID group_id;			// used for SL-23488
-	LLSelectMgr::getInstance()->selectGetGroup(group_id);  // sets group_id as a side effect SL-23488
+	(void)LLSelectMgr::getInstance()->selectGetGroup(group_id);  // sets group_id as a side effect SL-23488
 
 	// BUG? Check for all objects being editable?
 	bool editable = gAgent.isGodlike()
diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp
index b3c455f4ec..9ab9901896 100755
--- a/indra/newview/llpanelgrouplandmoney.cpp
+++ b/indra/newview/llpanelgrouplandmoney.cpp
@@ -194,7 +194,7 @@ public:
 
 	void requestGroupLandInfo();
 
-	int getStoredContribution();
+	S32 getStoredContribution();
 	void setYourContributionTextField(int contrib);
 	void setYourMaxContributionTextBox(int max);
 
@@ -343,14 +343,14 @@ bool LLPanelGroupLandMoney::impl::applyContribution()
 
 // Retrieves the land contribution for this agent that is currently
 // stored in the database, NOT what is currently entered in the text field
-int LLPanelGroupLandMoney::impl::getStoredContribution()
+S32 LLPanelGroupLandMoney::impl::getStoredContribution()
 {
 	LLGroupData group_data;
 
 	group_data.mContribution = 0;
-	gAgent.getGroupData(mPanel.mGroupID, group_data);
+	bool found_group = gAgent.getGroupData(mPanel.mGroupID, group_data);
 
-	return group_data.mContribution;
+    return found_group ? group_data.mContribution : 0;
 }
 
 // Fills in the text field with the contribution, contrib
diff --git a/indra/newview/llpanelmediasettingsgeneral.cpp b/indra/newview/llpanelmediasettingsgeneral.cpp
index 0b612ff535..f71d8f6ab1 100755
--- a/indra/newview/llpanelmediasettingsgeneral.cpp
+++ b/indra/newview/llpanelmediasettingsgeneral.cpp
@@ -469,7 +469,7 @@ bool LLPanelMediaSettingsGeneral::navigateHomeSelectedFace(bool only_if_current_
 	
 	bool all_face_media_navigated = false;
 	LLObjectSelectionHandle selected_objects =LLSelectMgr::getInstance()->getSelection();
-	selected_objects->getSelectedTEValue( &functor_navigate_media, all_face_media_navigated );
+	(void)selected_objects->getSelectedTEValue( &functor_navigate_media, all_face_media_navigated );
 	
 	// Note: we don't update the 'current URL' field until the media data itself changes
 
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index cfd27c7b65..760fa10fff 100755
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -314,10 +314,11 @@ void LLPanelPrimMediaControls::updateShape()
 	{
 		bool mini_controls = false;
 		LLMediaEntry *media_data = objectp->getTE(mTargetObjectFace)->getMediaData();
-		if (media_data && NULL != dynamic_cast<LLVOVolume*>(objectp))
+        LLVOVolume *vol = dynamic_cast<LLVOVolume*>(objectp);
+		if (media_data && vol)
 		{
 			// Don't show the media controls if we do not have permissions
-			enabled = dynamic_cast<LLVOVolume*>(objectp)->hasMediaPermission(media_data, LLVOVolume::MEDIA_PERM_CONTROL);
+			enabled = vol->hasMediaPermission(media_data, LLVOVolume::MEDIA_PERM_CONTROL);
 			mini_controls = (LLMediaEntry::MINI == media_data->getControls());
 		}
 		const bool is_hud = objectp->isHUDAttachment();
diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp
index c50ddf3054..95f89a6ebf 100755
--- a/indra/newview/lltoolbarview.cpp
+++ b/indra/newview/lltoolbarview.cpp
@@ -492,8 +492,7 @@ void LLToolBarView::onToolBarButtonAdded(LLView* button)
 		
 		if (incoming_floater && incoming_floater->isShown())
 		{
-			LLCallDialog* incoming = dynamic_cast<LLCallDialog *>(incoming_floater);
-			llassert(incoming);
+			LLCallDialog* incoming = static_cast<LLCallDialog *>(incoming_floater);
 			
 			LLDockControl* dock_control = incoming->getDockControl();
 			if (dock_control->getDock() == NULL)
@@ -504,8 +503,7 @@ void LLToolBarView::onToolBarButtonAdded(LLView* button)
 		
 		if (outgoing_floater && outgoing_floater->isShown())
 		{
-			LLCallDialog* outgoing = dynamic_cast<LLCallDialog *>(outgoing_floater);
-			llassert(outgoing);
+			LLCallDialog* outgoing = static_cast<LLCallDialog *>(outgoing_floater);
 			
 			LLDockControl* dock_control = outgoing->getDockControl();
 			if (dock_control->getDock() == NULL)
-- 
GitLab