diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 273e9c1ef6307a28bb5bcacec2c5e695450771f6..6f858cdeb36b558bb4033d5df7d24e0ef6890208 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)