From 22e69897db61a62794116eb81e8b413ac180b8e7 Mon Sep 17 00:00:00 2001
From: AndreyL ProductEngine <alihatskiy@productengine.com>
Date: Tue, 2 Aug 2016 06:22:43 +0300
Subject: [PATCH] MAINT-6605 Fix for the crash in LLClipboard::addToClipboard()
 - Added the exception handling

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

diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp
index 1d18cb2bb03..06fac190ed2 100644
--- a/indra/llui/llclipboard.cpp
+++ b/indra/llui/llclipboard.cpp
@@ -123,7 +123,15 @@ bool LLClipboard::copyToClipboard(const LLWString &src, S32 pos, S32 len, bool u
 // Concatenate the input string to the LL and the system clipboard
 bool LLClipboard::addToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary)
 {
-	mString = src.substr(pos, len);
+	try
+	{
+		mString = src.substr(pos, len);
+	}
+	catch (const std::exception& e)
+	{
+		LL_WARNS() << "Can't add the substring to clipboard: " << e.what() << LL_ENDL;
+		return false;
+	}
 	return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString));
 }
 
-- 
GitLab