From 06c2f24df9929951bbe67cf5187745e25dafa13a Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Tue, 25 Jul 2017 17:39:40 +0300
Subject: MAINT-7636 Crash in LLPanelClassifiedInfo::sendClickMessage(..)

---
 indra/newview/llpanelclassified.cpp | 57 ++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 5d1ae4ff10..b9b97f4cce 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -208,19 +208,21 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key)
 	LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoRequest(getClassifiedId());
 	gGenericDispatcher.addHandler("classifiedclickthrough", &sClassifiedClickThrough);
 
-	// While we're at it let's get the stats from the new table if that
-	// capability exists.
-	std::string url = gAgent.getRegion()->getCapability("SearchStatRequest");
-	if (!url.empty())
+	if (gAgent.getRegion())
 	{
-		LL_INFOS() << "Classified stat request via capability" << LL_ENDL;
-		LLSD body;
-        LLUUID classifiedId = getClassifiedId();
-		body["classified_id"] = classifiedId;
-        LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, body,
-            boost::bind(&LLPanelClassifiedInfo::handleSearchStatResponse, classifiedId, _1));
+		// While we're at it let's get the stats from the new table if that
+		// capability exists.
+		std::string url = gAgent.getRegion()->getCapability("SearchStatRequest");
+		if (!url.empty())
+		{
+			LL_INFOS() << "Classified stat request via capability" << LL_ENDL;
+			LLSD body;
+			LLUUID classifiedId = getClassifiedId();
+			body["classified_id"] = classifiedId;
+			LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, body,
+				boost::bind(&LLPanelClassifiedInfo::handleSearchStatResponse, classifiedId, _1));
+		}
 	}
-
 	// Update classified click stats.
 	// *TODO: Should we do this when opening not from search?
 	sendClickMessage("profile");
@@ -540,21 +542,24 @@ void LLPanelClassifiedInfo::sendClickMessage(
 		const LLVector3d& global_pos,
 		const std::string& sim_name)
 {
-	// You're allowed to click on your own ads to reassure yourself
-	// that the system is working.
-	LLSD body;
-	body["type"]			= type;
-	body["from_search"]		= from_search;
-	body["classified_id"]	= classified_id;
-	body["parcel_id"]		= parcel_id;
-	body["dest_pos_global"]	= global_pos.getValue();
-	body["region_name"]		= sim_name;
-
-	std::string url = gAgent.getRegion()->getCapability("SearchStatTracking");
-	LL_INFOS() << "Sending click msg via capability (url=" << url << ")" << LL_ENDL;
-	LL_INFOS() << "body: [" << body << "]" << LL_ENDL;
-    LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body,
-        "SearchStatTracking Click report sent.", "SearchStatTracking Click report NOT sent.");
+	if (gAgent.getRegion())
+	{
+		// You're allowed to click on your own ads to reassure yourself
+		// that the system is working.
+		LLSD body;
+		body["type"]			= type;
+		body["from_search"]		= from_search;
+		body["classified_id"]	= classified_id;
+		body["parcel_id"]		= parcel_id;
+		body["dest_pos_global"]	= global_pos.getValue();
+		body["region_name"]		= sim_name;
+
+		std::string url = gAgent.getRegion()->getCapability("SearchStatTracking");
+		LL_INFOS() << "Sending click msg via capability (url=" << url << ")" << LL_ENDL;
+		LL_INFOS() << "body: [" << body << "]" << LL_ENDL;
+        LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body,
+            "SearchStatTracking Click report sent.", "SearchStatTracking Click report NOT sent.");
+	}
 }
 
 void LLPanelClassifiedInfo::sendClickMessage(const std::string& type)
-- 
cgit v1.2.3