From 8247f51684ecc73cc60fa64b2fb0de3dce2a0c26 Mon Sep 17 00:00:00 2001
From: Stinson Linden <stinson@lindenlab.com>
Date: Fri, 2 May 2014 00:32:31 +0100
Subject: [PATCH] MAINT-4009: Patching the memory leak occurring in the
 scenario where avatar icon was being created, but the tab container did not
 have a button to accept the gieven icon.

---
 indra/llui/lltabcontainer.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 273e9c1ef63..6f858cdeb36 100755
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -1647,16 +1647,26 @@ void LLTabContainer::setTabImage(LLPanel* child, LLIconCtrl* icon)
 {
 	LLTabTuple* tuple = getTabByPanel(child);
 	LLCustomButtonIconCtrl* button;
+	bool hasButton = false;
 
 	if(tuple)
 	{
 		button = dynamic_cast<LLCustomButtonIconCtrl*>(tuple->mButton);
 		if(button)
 		{
+			hasButton = true;
 			button->setIcon(icon);
 			reshapeTuple(tuple);
 		}
 	}
+
+	if (!hasButton && (icon != NULL))
+	{
+		// It was assumed that the tab's button would take ownership of the icon pointer.
+		// But since the tab did not have a button, kill the icon to prevent the memory
+		// leak.
+		icon->die();
+	}
 }
 
 void LLTabContainer::reshapeTuple(LLTabTuple* tuple)
-- 
GitLab