From 827a9f7c2d98a10d09ab87b16c92a22295f21cde Mon Sep 17 00:00:00 2001
From: Stinson Linden <stinson@lindenlab.com>
Date: Fri, 2 May 2014 00:28:22 +0100
Subject: [PATCH] MAINT-4009: Patching the memory leak occurring in the
 scenario where toast panels were being created, but the screen channel were
 deciding not to display the given toasts.

---
 indra/newview/llscreenchannel.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp
index 6a840f3f400..8708fb87ee3 100755
--- a/indra/newview/llscreenchannel.cpp
+++ b/indra/newview/llscreenchannel.cpp
@@ -273,6 +273,14 @@ void LLScreenChannel::addToast(const LLToast::Params& p)
 			// only cancel notification if it isn't being used in IM session
 			LLNotifications::instance().cancel(notification);
 		}
+
+		// It was assumed that the toast would take ownership of the panel pointer.
+		// But since we have decided not to display the toast, kill the panel to
+		// prevent the memory leak.
+		if (p.panel != NULL)
+		{
+			p.panel()->die();
+		}
 		return;
 	}
 
-- 
GitLab